From a417d6dc5abadbe5d74ee7c0375099ca1ae7744a Mon Sep 17 00:00:00 2001 From: Adhiraj Singh Date: Thu, 25 Nov 2021 00:38:13 +0530 Subject: [PATCH] fix: return mutations on patch --- src/Socket/chats.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Socket/chats.ts b/src/Socket/chats.ts index c70b5f3..9881dfc 100644 --- a/src/Socket/chats.ts +++ b/src/Socket/chats.ts @@ -208,7 +208,7 @@ export const makeChatsSocket = (config: SocketConfig) => { }) const decoded = await extractSyncdPatches(result) // extract from binary node - + const totalMutations: ChatMutation[] = [] for(const key in decoded) { const name = key as WAPatchName const { patches, snapshot } = decoded[name] @@ -226,17 +226,23 @@ export const makeChatsSocket = (config: SocketConfig) => { logger.info(`synced ${name} to v${newState.version}`) processSyncActions(newMutations) + + totalMutations.push(...newMutations) } } + + return totalMutations } const resyncAppState = async(collections: WAPatchName[], returnSnapshot: boolean = false) => { + let result: ChatMutation[] try { - await resyncAppStateInternal(collections, returnSnapshot) + result = await resyncAppStateInternal(collections, false, returnSnapshot) } catch(error) { logger.info({ collections, error: error.stack }, 'failed to sync state from version, trying from scratch') - await resyncAppStateInternal(collections, true, true) + result = await resyncAppStateInternal(collections, true, true) } + return result } /**