mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
refactor: less code duplication for timestamp
This commit is contained in:
@@ -424,12 +424,10 @@ export const chatModificationToAppPatch = (
|
|||||||
lastMessageTimestamp: lastMessages[lastMessages.length-1].messageTimestamp,
|
lastMessageTimestamp: lastMessages[lastMessages.length-1].messageTimestamp,
|
||||||
messages: lastMessages
|
messages: lastMessages
|
||||||
}
|
}
|
||||||
const timestamp = Date.now()
|
|
||||||
let patch: WAPatchCreate
|
let patch: WAPatchCreate
|
||||||
if('mute' in mod) {
|
if('mute' in mod) {
|
||||||
patch = {
|
patch = {
|
||||||
syncAction: {
|
syncAction: {
|
||||||
timestamp,
|
|
||||||
muteAction: {
|
muteAction: {
|
||||||
muted: !!mod.mute,
|
muted: !!mod.mute,
|
||||||
muteEndTimestamp: mod.mute || undefined
|
muteEndTimestamp: mod.mute || undefined
|
||||||
@@ -443,7 +441,6 @@ export const chatModificationToAppPatch = (
|
|||||||
} else if('archive' in mod) {
|
} else if('archive' in mod) {
|
||||||
patch = {
|
patch = {
|
||||||
syncAction: {
|
syncAction: {
|
||||||
timestamp,
|
|
||||||
archiveChatAction: {
|
archiveChatAction: {
|
||||||
archived: !!mod.archive,
|
archived: !!mod.archive,
|
||||||
messageRange
|
messageRange
|
||||||
@@ -457,7 +454,6 @@ export const chatModificationToAppPatch = (
|
|||||||
} else if('markRead' in mod) {
|
} else if('markRead' in mod) {
|
||||||
patch = {
|
patch = {
|
||||||
syncAction: {
|
syncAction: {
|
||||||
timestamp,
|
|
||||||
markChatAsReadAction: {
|
markChatAsReadAction: {
|
||||||
read: mod.markRead,
|
read: mod.markRead,
|
||||||
messageRange
|
messageRange
|
||||||
@@ -475,7 +471,6 @@ export const chatModificationToAppPatch = (
|
|||||||
const key = mod.clear.message
|
const key = mod.clear.message
|
||||||
patch = {
|
patch = {
|
||||||
syncAction: {
|
syncAction: {
|
||||||
timestamp,
|
|
||||||
deleteMessageForMeAction: {
|
deleteMessageForMeAction: {
|
||||||
deleteMedia: false
|
deleteMedia: false
|
||||||
}
|
}
|
||||||
@@ -489,5 +484,8 @@ export const chatModificationToAppPatch = (
|
|||||||
} else {
|
} else {
|
||||||
throw new Boom('not supported')
|
throw new Boom('not supported')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
patch.syncAction.timestamp = Date.now()
|
||||||
|
|
||||||
return patch
|
return patch
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user