From e710ed96f9e8b7b1c27b4c665fd6fd6c8d06e037 Mon Sep 17 00:00:00 2001 From: Adhiraj Singh Date: Mon, 17 Oct 2022 12:53:47 +0530 Subject: [PATCH] fix: unarchive chats if reaction to my message --- src/Utils/process-message.ts | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/Utils/process-message.ts b/src/Utils/process-message.ts index 5ef9529..7c698c9 100644 --- a/src/Utils/process-message.ts +++ b/src/Utils/process-message.ts @@ -77,21 +77,28 @@ const processMessage = async( const { accountSettings } = creds const chat: Partial = { id: jidNormalizedUser(message.key.remoteJid!) } + const isRealMsg = isRealMessage(message) - if(isRealMessage(message)) { + if(isRealMsg) { chat.conversationTimestamp = toNumber(message.messageTimestamp) // only increment unread count if not CIPHERTEXT and from another person if(shouldIncrementChatUnread(message)) { chat.unreadCount = (chat.unreadCount || 0) + 1 } - - if(accountSettings?.unarchiveChats) { - chat.archived = false - chat.readOnly = false - } } const content = normalizeMessageContent(message.message) + + // unarchive chat if it's a real message, or someone reacted to our message + // and we've the unarchive chats setting on + if( + (isRealMsg || content?.reactionMessage?.key?.fromMe) + && accountSettings?.unarchiveChats + ) { + chat.archived = false + chat.readOnly = false + } + const protocolMsg = content?.protocolMessage if(protocolMsg) { switch (protocolMsg.type) {