whatsapp-web.js 1.16.6 → 1.16.7
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/README.md +1 -1
- package/package.json +1 -1
- package/src/Client.js +5 -4
- package/src/structures/Chat.js +2 -2
- package/src/util/Injected.js +4 -3
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[](https://www.npmjs.com/package/whatsapp-web.js) [](https://depfu.com/github/pedroslopez/whatsapp-web.js?project_id=9765) ](https://www.npmjs.com/package/whatsapp-web.js) [](https://depfu.com/github/pedroslopez/whatsapp-web.js?project_id=9765)  [](https://discord.gg/H7DqQs4)
|
|
2
2
|
|
|
3
3
|
# whatsapp-web.js
|
|
4
4
|
A WhatsApp API client that connects through the WhatsApp Web browser app
|
package/package.json
CHANGED
package/src/Client.js
CHANGED
|
@@ -809,8 +809,9 @@ class Client extends EventEmitter {
|
|
|
809
809
|
return true;
|
|
810
810
|
}
|
|
811
811
|
const MAX_PIN_COUNT = 3;
|
|
812
|
-
|
|
813
|
-
|
|
812
|
+
const chatModels = window.Store.Chat.getModelsArray();
|
|
813
|
+
if (chatModels.length > MAX_PIN_COUNT) {
|
|
814
|
+
let maxPinned = chatModels[MAX_PIN_COUNT - 1].pin;
|
|
814
815
|
if (maxPinned) {
|
|
815
816
|
return false;
|
|
816
817
|
}
|
|
@@ -1056,7 +1057,7 @@ class Client extends EventEmitter {
|
|
|
1056
1057
|
async getChatsByLabelId(labelId) {
|
|
1057
1058
|
const chatIds = await this.pupPage.evaluate(async (labelId) => {
|
|
1058
1059
|
const label = window.Store.Label.get(labelId);
|
|
1059
|
-
const labelItems = label.labelItemCollection.
|
|
1060
|
+
const labelItems = label.labelItemCollection.getModelsArray();
|
|
1060
1061
|
return labelItems.reduce((result, item) => {
|
|
1061
1062
|
if (item.parentType === 'Chat') {
|
|
1062
1063
|
result.push(item.parentId);
|
|
@@ -1074,7 +1075,7 @@ class Client extends EventEmitter {
|
|
|
1074
1075
|
*/
|
|
1075
1076
|
async getBlockedContacts() {
|
|
1076
1077
|
const blockedContacts = await this.pupPage.evaluate(() => {
|
|
1077
|
-
let chatIds = window.Store.Blocklist.
|
|
1078
|
+
let chatIds = window.Store.Blocklist.getModelsArray().map(a => a.id._serialized);
|
|
1078
1079
|
return Promise.all(chatIds.map(id => window.WWebJS.getContact(id)));
|
|
1079
1080
|
});
|
|
1080
1081
|
|
package/src/structures/Chat.js
CHANGED
|
@@ -179,11 +179,11 @@ class Chat extends Base {
|
|
|
179
179
|
const msgFilter = m => !m.isNotification; // dont include notification messages
|
|
180
180
|
|
|
181
181
|
const chat = window.Store.Chat.get(chatId);
|
|
182
|
-
let msgs = chat.msgs.
|
|
182
|
+
let msgs = chat.msgs.getModelsArray().filter(msgFilter);
|
|
183
183
|
|
|
184
184
|
if (searchOptions && searchOptions.limit > 0) {
|
|
185
185
|
while (msgs.length < searchOptions.limit) {
|
|
186
|
-
const loadedMessages = await
|
|
186
|
+
const loadedMessages = await window.Store.ConversationMsgs.loadEarlierMsgs(chat);
|
|
187
187
|
if (!loadedMessages) break;
|
|
188
188
|
msgs = [...loadedMessages.filter(msgFilter), ...msgs];
|
|
189
189
|
}
|
package/src/util/Injected.js
CHANGED
|
@@ -48,6 +48,7 @@ exports.ExposeStore = (moduleRaidStr) => {
|
|
|
48
48
|
window.Store.JoinInviteV4 = window.mR.findModule('sendJoinGroupViaInviteV4')[0];
|
|
49
49
|
window.Store.findCommonGroups = window.mR.findModule('findCommonGroups')[0].findCommonGroups;
|
|
50
50
|
window.Store.StatusUtils = window.mR.findModule('setMyStatus')[0];
|
|
51
|
+
window.Store.ConversationMsgs = window.mR.findModule('loadEarlierMsgs')[0];
|
|
51
52
|
window.Store.StickerTools = {
|
|
52
53
|
...window.mR.findModule('toWebpSticker')[0],
|
|
53
54
|
...window.mR.findModule('addWebpMetadata')[0]
|
|
@@ -416,7 +417,7 @@ exports.LoadUtils = () => {
|
|
|
416
417
|
};
|
|
417
418
|
|
|
418
419
|
window.WWebJS.getChats = async () => {
|
|
419
|
-
const chats = window.Store.Chat.
|
|
420
|
+
const chats = window.Store.Chat.getModelsArray();
|
|
420
421
|
|
|
421
422
|
const chatPromises = chats.map(chat => window.WWebJS.getChatModel(chat));
|
|
422
423
|
return await Promise.all(chatPromises);
|
|
@@ -448,7 +449,7 @@ exports.LoadUtils = () => {
|
|
|
448
449
|
};
|
|
449
450
|
|
|
450
451
|
window.WWebJS.getContacts = () => {
|
|
451
|
-
const contacts = window.Store.Contact.
|
|
452
|
+
const contacts = window.Store.Contact.getModelsArray();
|
|
452
453
|
return contacts.map(contact => window.WWebJS.getContactModel(contact));
|
|
453
454
|
};
|
|
454
455
|
|
|
@@ -541,7 +542,7 @@ exports.LoadUtils = () => {
|
|
|
541
542
|
};
|
|
542
543
|
|
|
543
544
|
window.WWebJS.getLabels = () => {
|
|
544
|
-
const labels = window.Store.Label.
|
|
545
|
+
const labels = window.Store.Label.getModelsArray();
|
|
545
546
|
return labels.map(label => window.WWebJS.getLabelModel(label));
|
|
546
547
|
};
|
|
547
548
|
|