From ad9314c1f2dfb16fa8ead9fb76ebda0a7617d8bd Mon Sep 17 00:00:00 2001 From: Adhiraj Singh Date: Mon, 7 Mar 2022 19:21:04 +0530 Subject: [PATCH] fix: only update last account sync when required --- src/Socket/chats.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Socket/chats.ts b/src/Socket/chats.ts index 2bc5bc4..5b30f43 100644 --- a/src/Socket/chats.ts +++ b/src/Socket/chats.ts @@ -648,13 +648,16 @@ export const makeChatsSocket = (config: SocketConfig) => { const type = attrs.type switch (type) { case 'account_sync': - let { lastAccountSyncTimestamp } = authState.creds - if(lastAccountSyncTimestamp) { - await updateAccountSyncTimestamp(lastAccountSyncTimestamp) + if(attrs.timestamp) { + let { lastAccountSyncTimestamp } = authState.creds + if(lastAccountSyncTimestamp) { + await updateAccountSyncTimestamp(lastAccountSyncTimestamp) + } + + lastAccountSyncTimestamp = +attrs.timestamp + ev.emit('creds.update', { lastAccountSyncTimestamp }) } - lastAccountSyncTimestamp = +attrs.timestamp - ev.emit('creds.update', { lastAccountSyncTimestamp }) break default: logger.info({ node }, 'received unknown sync')