feat: add "receivedInitialSync" connection update

This commit is contained in:
Adhiraj Singh
2022-08-19 10:48:27 +05:30
parent ebd92e0337
commit c76c2afa0c
5 changed files with 18 additions and 17 deletions

View File

@@ -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')
}

View File

@@ -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
}

View File

@@ -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 }

View File

@@ -85,5 +85,4 @@ export type WABusinessProfile = {
address?: string
}
export type CurveKeyPair = { private: Uint8Array; public: Uint8Array }

View File

@@ -128,6 +128,7 @@ export const initAuthCreds = (): AuthenticationCreds => {
processedHistoryMessages: [],
nextPreKeyId: 1,
firstUnuploadedPreKeyId: 1,
accountSyncCounter: 0,
accountSettings: {
unarchiveChats: false
}