fix: GroupChat.setPicture (#3593)

* fix: find collection if not in cache

* style: use camelcase
This commit is contained in:
alechkos 2025-06-05 20:21:38 +03:00 • committed by GitHub
commit d2fe324e5b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -843,14 +843,14 @@ 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;