From d2fe324e5ba19880909bf338289e5500b8a9f1bc Mon Sep 17 00:00:00 2001 From: alechkos <93551621+alechkos@users.noreply.github.com> Date: Thu, 5 Jun 2025 20:21:38 +0300 Subject: [PATCH] fix: `GroupChat.setPicture` (#3593) * fix: find collection if not in cache * style: use camelcase --- src/util/Injected/Utils.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/util/Injected/Utils.js b/src/util/Injected/Utils.js index a5a1d87..75cf0e1 100644 --- a/src/util/Injected/Utils.js +++ b/src/util/Injected/Utils.js @@ -843,19 +843,19 @@ exports.LoadUtils = () => { }); }; - window.WWebJS.setPicture = async (chatid, media) => { + window.WWebJS.setPicture = async (chatId, media) => { const thumbnail = await window.WWebJS.cropAndResizeImage(media, { asDataUrl: true, mimetype: 'image/jpeg', size: 96 }); const profilePic = await window.WWebJS.cropAndResizeImage(media, { asDataUrl: true, mimetype: 'image/jpeg', size: 640 }); - const chatWid = window.Store.WidFactory.createWid(chatid); + const chatWid = window.Store.WidFactory.createWid(chatId); try { - const collection = window.Store.ProfilePicThumb.get(chatid); - if (!collection.canSet()) return; + const collection = window.Store.ProfilePicThumb.get(chatId) || await window.Store.ProfilePicThumb.find(chatId); + if (!collection?.canSet()) return false; const res = await window.Store.GroupUtils.sendSetPicture(chatWid, thumbnail, profilePic); return res ? res.status === 200 : false; } catch (err) { - if(err.name === 'ServerStatusCodeError') return false; + if (err.name === 'ServerStatusCodeError') return false; throw err; } };