diff --git a/src/Store/make-in-memory-store.ts b/src/Store/make-in-memory-store.ts index 03abc3d..aab2785 100644 --- a/src/Store/make-in-memory-store.ts +++ b/src/Store/make-in-memory-store.ts @@ -12,7 +12,7 @@ import makeOrderedDictionary from './make-ordered-dictionary' type WASocket = ReturnType export const waChatKey = (pin: boolean) => ({ - key: (c: Chat) => (pin ? (c.pin ? '1' : '0') : '') + (c.archive ? '0' : '1') + (c.conversationTimestamp ? c.conversationTimestamp.toString(16).padStart(8, '0') : '') + c.id, + key: (c: Chat) => (pin ? (c.pinned ? '1' : '0') : '') + (c.archived ? '0' : '1') + (c.conversationTimestamp ? c.conversationTimestamp.toString(16).padStart(8, '0') : '') + c.id, compare: (k1: string, k2: string) => k2.localeCompare (k1) }) diff --git a/src/Types/Chat.ts b/src/Types/Chat.ts index d21c70f..6d9eff2 100644 --- a/src/Types/Chat.ts +++ b/src/Types/Chat.ts @@ -33,13 +33,7 @@ export type WAPatchCreate = { operation: proto.SyncdMutation.SyncdOperation } -export type Chat = proto.IConversation & { - /** unix timestamp of date when mute ends, if applicable */ - mute?: number | null - /** timestamp of when pinned */ - pin?: number | null - archive?: boolean -} +export type Chat = proto.IConversation /** * the last messages in a chat, sorted reverse-chronologically. That is, the latest message should be first in the chat diff --git a/src/Utils/chat-utils.ts b/src/Utils/chat-utils.ts index a243789..56b6379 100644 --- a/src/Utils/chat-utils.ts +++ b/src/Utils/chat-utils.ts @@ -631,7 +631,7 @@ export const processSyncAction = ( [ { id, - mute: action.muteAction?.muted ? + muteEndTime: action.muteAction?.muted ? toNumber(action.muteAction!.muteEndTimestamp!) : null } @@ -657,9 +657,9 @@ export const processSyncAction = ( // basically we don't need to fire an "archive" update if the chat is being marked unarchvied // this only applies for the initial sync if(isInitialSync && !archiveAction.archived) { - ev.emit('chats.update', [{ id, archive: false }]) + ev.emit('chats.update', [{ id, archived: false }]) } else { - ev.emit('chats.update', [{ id, archive: !!archiveAction?.archived }]) + ev.emit('chats.update', [{ id, archived: !!archiveAction?.archived }]) } } } else if(action?.markChatAsReadAction) { @@ -692,7 +692,7 @@ export const processSyncAction = ( ev.emit('creds.update', { me: { ...me, name: action?.pushNameSetting?.name! } }) } } else if(action?.pinAction) { - ev.emit('chats.update', [{ id, pin: action.pinAction?.pinned ? toNumber(action.timestamp!) : null }]) + ev.emit('chats.update', [{ id, pinned: action.pinAction?.pinned ? toNumber(action.timestamp!) : null }]) } else if(action?.unarchiveChatsSetting) { const unarchiveChats = !!action.unarchiveChatsSetting.unarchiveChats ev.emit('creds.update', { accountSettings: { unarchiveChats } }) diff --git a/src/Utils/process-message.ts b/src/Utils/process-message.ts index 5202230..acf2eec 100644 --- a/src/Utils/process-message.ts +++ b/src/Utils/process-message.ts @@ -81,7 +81,7 @@ const processMessage = async( } if(accountSettings?.unarchiveChats) { - chat.archive = false + chat.archived = false chat.readOnly = false } }