whatsapp-web.js 1.30.1-alpha.0 → 1.30.1-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "whatsapp-web.js",
3
- "version": "1.30.1-alpha.0",
3
+ "version": "1.30.1-alpha.2",
4
4
  "description": "Library for interacting with the WhatsApp Web API ",
5
5
  "main": "./index.js",
6
6
  "typings": "./index.d.ts",
@@ -48,9 +48,7 @@ exports.LoadUtils = () => {
48
48
  if (options.quotedMessageId) {
49
49
  let quotedMessage = window.Store.Msg.get(options.quotedMessageId);
50
50
  !quotedMessage && (quotedMessage = (await window.Store.Msg.getMessagesById([options.quotedMessageId]))?.messages?.[0]);
51
-
52
- if (quotedMessage['messages']?.length == 1) {
53
- quotedMessage = quotedMessage['messages'][0];
51
+ if (quotedMessage) {
54
52
 
55
53
  const canReply = window.Store.ReplyUtils
56
54
  ? window.Store.ReplyUtils.canReplyMsg(quotedMessage.unsafe())
@@ -558,8 +556,8 @@ exports.LoadUtils = () => {
558
556
  const chatWid = window.Store.WidFactory.createWid(chat.id._serialized);
559
557
  await window.Store.GroupMetadata.update(chatWid);
560
558
  chat.groupMetadata.participants._models
561
- .filter(x => x.id._serialized.endsWith('@lid'))
562
- .forEach(x => { x.id = x.contact.phoneNumber; });
559
+ .filter(x => x.id?._serialized?.endsWith('@lid'))
560
+ .forEach(x => x.contact?.phoneNumber && (x.id = x.contact.phoneNumber));
563
561
  model.groupMetadata = chat.groupMetadata.serialize();
564
562
  model.isReadOnly = chat.groupMetadata.announce;
565
563
  }
@@ -845,19 +843,19 @@ exports.LoadUtils = () => {
845
843
  });
846
844
  };
847
845
 
848
- window.WWebJS.setPicture = async (chatid, media) => {
846
+ window.WWebJS.setPicture = async (chatId, media) => {
849
847
  const thumbnail = await window.WWebJS.cropAndResizeImage(media, { asDataUrl: true, mimetype: 'image/jpeg', size: 96 });
850
848
  const profilePic = await window.WWebJS.cropAndResizeImage(media, { asDataUrl: true, mimetype: 'image/jpeg', size: 640 });
851
849
 
852
- const chatWid = window.Store.WidFactory.createWid(chatid);
850
+ const chatWid = window.Store.WidFactory.createWid(chatId);
853
851
  try {
854
- const collection = window.Store.ProfilePicThumb.get(chatid);
855
- if (!collection.canSet()) return;
852
+ const collection = window.Store.ProfilePicThumb.get(chatId) || await window.Store.ProfilePicThumb.find(chatId);
853
+ if (!collection?.canSet()) return false;
856
854
 
857
855
  const res = await window.Store.GroupUtils.sendSetPicture(chatWid, thumbnail, profilePic);
858
856
  return res ? res.status === 200 : false;
859
857
  } catch (err) {
860
- if(err.name === 'ServerStatusCodeError') return false;
858
+ if (err.name === 'ServerStatusCodeError') return false;
861
859
  throw err;
862
860
  }
863
861
  };