mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
Update WhatsAppWeb.Session.js
This commit is contained in:
@@ -107,12 +107,14 @@ module.exports = {
|
|||||||
const chatUpdate = (json) => {
|
const chatUpdate = (json) => {
|
||||||
const isLast = json[1].last
|
const isLast = json[1].last
|
||||||
json = json[2]
|
json = json[2]
|
||||||
for (var k = json.length-1;k >= 0;k--) {
|
if (json) {
|
||||||
const message = json[k][2]
|
for (var k = json.length-1;k >= 0;k--) {
|
||||||
const jid = message.key.remoteJid.replace ("@s.whatsapp.net", "@c.us")
|
const message = json[k][2]
|
||||||
if (!message.key.fromMe && unreadMap[jid] > 0) { // only forward if the message is from the sender
|
const jid = message.key.remoteJid.replace ("@s.whatsapp.net", "@c.us")
|
||||||
unreadMessages.push (message)
|
if (!message.key.fromMe && unreadMap[jid] > 0) { // only forward if the message is from the sender
|
||||||
unreadMap[jid] -= 1 // reduce
|
unreadMessages.push (message)
|
||||||
|
unreadMap[jid] -= 1 // reduce
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isLast) {
|
if (isLast) {
|
||||||
@@ -131,7 +133,7 @@ module.exports = {
|
|||||||
const waitForChats = this.registerCallbackOneTime (["response", "type:chat"]).then (json => {
|
const waitForChats = this.registerCallbackOneTime (["response", "type:chat"]).then (json => {
|
||||||
chats = json[2] // chats data (log json to see what it looks like)
|
chats = json[2] // chats data (log json to see what it looks like)
|
||||||
chats.forEach (chat => unreadMap [chat[1].jid] = chat[1].count) // store the number of unread messages for each sender
|
chats.forEach (chat => unreadMap [chat[1].jid] = chat[1].count) // store the number of unread messages for each sender
|
||||||
if (chats.length > 0) {
|
if (chats && chats.length > 0) {
|
||||||
return waitForConvos ()
|
return waitForConvos ()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user