diff --git a/src/Socket/chats.ts b/src/Socket/chats.ts index e37753c..e17a435 100644 --- a/src/Socket/chats.ts +++ b/src/Socket/chats.ts @@ -41,6 +41,9 @@ export const makeChatsSocket = (config: SocketConfig) => { 'doing initial app state sync' ) await resyncMainAppState(recvChats) + + const accountSyncCounter = (authState.creds.accountSyncCounter || 0) + 1 + ev.emit('creds.update', { accountSyncCounter }) } else { logger.warn('connection closed before app state sync') } diff --git a/src/Types/Auth.ts b/src/Types/Auth.ts index 67373ca..2ccb9db 100644 --- a/src/Types/Auth.ts +++ b/src/Types/Auth.ts @@ -48,6 +48,8 @@ export type AuthenticationCreds = SignalCreds & { platform?: string processedHistoryMessages: MinimalMessage[] + /** number of times history & app state has been synced */ + accountSyncCounter: number accountSettings: AccountSettings } diff --git a/src/Types/Chat.ts b/src/Types/Chat.ts index 71e1a8e..c37da77 100644 --- a/src/Types/Chat.ts +++ b/src/Types/Chat.ts @@ -51,31 +51,27 @@ export type ChatModification = { archive: boolean lastMessages: LastMessageList - } | - { - pushNameSetting: string - } | - { - pin: boolean - } | - { + } + | { pushNameSetting: string } + | { pin: boolean } + | { /** mute for duration, or provide timestamp of mute to remove*/ mute: number | null - } | - { + } + | { clear: 'all' | { messages: {id: string, fromMe?: boolean, timestamp: number}[] } - } | - { + } + | { star: { messages: { id: string, fromMe?: boolean }[], star: boolean } - } | - { + } + | { markRead: boolean lastMessages: LastMessageList - } | - { delete: true, lastMessages: LastMessageList } + } + | { delete: true, lastMessages: LastMessageList } export type InitialReceivedChatsState = { [jid: string]: { lastMsgRecvTimestamp: number } diff --git a/src/Types/index.ts b/src/Types/index.ts index 232ae4a..e35c67c 100644 --- a/src/Types/index.ts +++ b/src/Types/index.ts @@ -85,5 +85,4 @@ export type WABusinessProfile = { address?: string } - export type CurveKeyPair = { private: Uint8Array; public: Uint8Array } \ No newline at end of file diff --git a/src/Utils/auth-utils.ts b/src/Utils/auth-utils.ts index 31d0455..17f09c2 100644 --- a/src/Utils/auth-utils.ts +++ b/src/Utils/auth-utils.ts @@ -128,6 +128,7 @@ export const initAuthCreds = (): AuthenticationCreds => { processedHistoryMessages: [], nextPreKeyId: 1, firstUnuploadedPreKeyId: 1, + accountSyncCounter: 0, accountSettings: { unarchiveChats: false }