feat: (hopefully) correctly implement account timestamp sync

This commit is contained in:
Adhiraj Singh
2021-11-25 13:52:18 +05:30
parent c07c013a90
commit f5fcaa36f3
2 changed files with 10 additions and 3 deletions

View File

@@ -472,18 +472,23 @@ export const makeChatsSocket = (config: SocketConfig) => {
ws.on('CB:presence', handlePresenceUpdate)
ws.on('CB:chatstate', handlePresenceUpdate)
/*ws.on('CB:ib,,dirty', async(node: BinaryNode) => {
ws.on('CB:ib,,dirty', async(node: BinaryNode) => {
const { attrs } = getBinaryNodeChild(node, 'dirty')
const type = attrs.type
switch(type) {
case 'account_sync':
await updateAccountSyncTimestamp(attrs.timestamp)
let { lastAccountSyncTimestamp } = authState.creds
if(lastAccountSyncTimestamp) {
await updateAccountSyncTimestamp(lastAccountSyncTimestamp)
}
lastAccountSyncTimestamp = +attrs.timestamp
ev.emit('creds.update', { lastAccountSyncTimestamp })
break
default:
logger.info({ node }, `received unknown sync`)
break
}
})*/
})
ws.on('CB:notification,type:server_sync', (node: BinaryNode) => {
const update = getBinaryNodeChild(node, 'collection')

View File

@@ -39,6 +39,8 @@ export type AuthenticationCreds = SignalCreds & {
firstUnuploadedPreKeyId: number
serverHasPreKeys: boolean
nextPreKeyId: number
lastAccountSyncTimestamp?: number
}
type Awaitable<T> = T | Promise<T>