From 2018653bcaec9290cd2ca47ef326e0b0c10a3cad Mon Sep 17 00:00:00 2001 From: Adhiraj Singh Date: Wed, 8 Jul 2020 15:26:11 +0530 Subject: [PATCH] Include archive/read_only in chats --- src/WAConnection/Connect.ts | 3 ++- src/WAConnection/Constants.ts | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/WAConnection/Connect.ts b/src/WAConnection/Connect.ts index 895bfda..afdc3d3 100644 --- a/src/WAConnection/Connect.ts +++ b/src/WAConnection/Connect.ts @@ -113,8 +113,9 @@ export default class WAConnectionConnector extends WAConnectionValidator { const waitForChats = async () => { const json = await this.registerCallbackOneTime(['response', 'type:chat']) json[2].forEach(chat => { + chat[1].count = parseInt(chat[1].count) + chat[1].messages = [] chats.push(chat[1]) // chats data (log json to see what it looks like) - chats[chats.length-1].messages = [] // store the number of unread messages for each sender chatMap[chat[1].jid] = {index: chats.length-1, count: chat[1].count} //chat[1].count }) diff --git a/src/WAConnection/Constants.ts b/src/WAConnection/Constants.ts index ebd009c..b7682c4 100644 --- a/src/WAConnection/Constants.ts +++ b/src/WAConnection/Constants.ts @@ -55,7 +55,9 @@ export interface WAContact { } export interface WAChat { t: string - count: string + count: number + archive?: 'true' | 'false' + read_only?: 'true' | 'false' spam: 'false' | 'true' jid: string modify_tag: string