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,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 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 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 { try {
const collection = window.Store.ProfilePicThumb.get(chatid); const collection = window.Store.ProfilePicThumb.get(chatId) || await window.Store.ProfilePicThumb.find(chatId);
if (!collection.canSet()) return; if (!collection?.canSet()) return false;
const res = await window.Store.GroupUtils.sendSetPicture(chatWid, thumbnail, profilePic); const res = await window.Store.GroupUtils.sendSetPicture(chatWid, thumbnail, profilePic);
return res ? res.status === 200 : false; return res ? res.status === 200 : false;
} catch (err) { } catch (err) {
if(err.name === 'ServerStatusCodeError') return false; if (err.name === 'ServerStatusCodeError') return false;
throw err; throw err;
} }
}; };