fix: GroupChat.setPicture (#3593)
* fix: find collection if not in cache * style: use camelcase
This commit is contained in:
parent
e1b0cdc852
commit
d2fe324e5b
1 changed files with 5 additions and 5 deletions
|
|
@ -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;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue