From e547310a193f4f88ecec2e37b6bbed0af6d49617 Mon Sep 17 00:00:00 2001 From: Adhiraj Singh Date: Mon, 7 Nov 2022 17:22:19 +0530 Subject: [PATCH] fix: add history msg to creds.update to prevent race condition --- src/Utils/process-message.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/Utils/process-message.ts b/src/Utils/process-message.ts index 02c94a21..2a9c0011 100644 --- a/src/Utils/process-message.ts +++ b/src/Utils/process-message.ts @@ -125,19 +125,19 @@ const processMessage = async( }, 'got history notification') if(process) { - const data = await downloadAndProcessHistorySyncNotification( - histNotification, - options - ) - - ev.emit('messaging-history.set', { ...data, isLatest }) - ev.emit('creds.update', { processedHistoryMessages: [ ...(creds.processedHistoryMessages || []), { key: message.key, messageTimestamp: message.messageTimestamp } ] }) + + const data = await downloadAndProcessHistorySyncNotification( + histNotification, + options + ) + + ev.emit('messaging-history.set', { ...data, isLatest }) } break @@ -152,8 +152,6 @@ const processMessage = async( const strKeyId = Buffer.from(keyId!.keyId!).toString('base64') newKeys.push(strKeyId) - logger?.trace({ strKeyId }, 'got app state sync key') - await keyStore.set({ 'app-state-sync-key': { [strKeyId]: keyData! } }) newAppStateSyncKeyId = strKeyId