From 99619c4c42aa3bfdf39e2b038c1ee71883c3da66 Mon Sep 17 00:00:00 2001 From: Adhiraj Singh Date: Thu, 25 Nov 2021 13:35:03 +0530 Subject: [PATCH] refactor: less code duplication for timestamp --- src/Utils/chat-utils.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Utils/chat-utils.ts b/src/Utils/chat-utils.ts index a496a97..b61521a 100644 --- a/src/Utils/chat-utils.ts +++ b/src/Utils/chat-utils.ts @@ -424,12 +424,10 @@ export const chatModificationToAppPatch = ( lastMessageTimestamp: lastMessages[lastMessages.length-1].messageTimestamp, messages: lastMessages } - const timestamp = Date.now() let patch: WAPatchCreate if('mute' in mod) { patch = { syncAction: { - timestamp, muteAction: { muted: !!mod.mute, muteEndTimestamp: mod.mute || undefined @@ -443,7 +441,6 @@ export const chatModificationToAppPatch = ( } else if('archive' in mod) { patch = { syncAction: { - timestamp, archiveChatAction: { archived: !!mod.archive, messageRange @@ -457,7 +454,6 @@ export const chatModificationToAppPatch = ( } else if('markRead' in mod) { patch = { syncAction: { - timestamp, markChatAsReadAction: { read: mod.markRead, messageRange @@ -475,7 +471,6 @@ export const chatModificationToAppPatch = ( const key = mod.clear.message patch = { syncAction: { - timestamp, deleteMessageForMeAction: { deleteMedia: false } @@ -489,5 +484,8 @@ export const chatModificationToAppPatch = ( } else { throw new Boom('not supported') } + + patch.syncAction.timestamp = Date.now() + return patch } \ No newline at end of file