From 45503898b058de939bd6af6062ad4b96cf06903b Mon Sep 17 00:00:00 2001 From: Adhiraj Singh Date: Thu, 29 Apr 2021 23:12:01 +0530 Subject: [PATCH] read bug fix --- src/WAConnection/4.Events.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/WAConnection/4.Events.ts b/src/WAConnection/4.Events.ts index f16723c..02c361b 100644 --- a/src/WAConnection/4.Events.ts +++ b/src/WAConnection/4.Events.ts @@ -377,12 +377,15 @@ export class WAConnection extends Base { this.on ('CB:action,,read', async json => { const update = json[2][0][1] const jid = whatsappID(update.jid) - const chat = this.chats.get (jid) || await this.chatAdd (jid) - - if (update.type === 'false') chat.count = -1 - else chat.count = 0 - - this.emit ('chat-update', { jid: chat.jid, count: chat.count }) + const chat = this.chats.get (jid) + if(chat) { + if (update.type === 'false') chat.count = -1 + else chat.count = 0 + + this.emit ('chat-update', { jid: chat.jid, count: chat.count }) + } else { + this.logger.warn('recieved read update for unknown chat ' + jid) + } }) this.on ('qr', qr => QR.generate(qr, { small: true }))