feat: export resyncmainappstate

This commit is contained in:
Adhiraj Singh
2021-11-19 17:41:57 +05:30
parent 9f196663e8
commit 79100a3164

View File

@@ -302,6 +302,20 @@ export const makeChatsSocket = (config: SocketConfig) => {
} }
} }
const resyncMainAppState = async() => {
logger.debug('resyncing main app state')
await (
mutationMutex.mutex(
() => resyncAppState([ 'critical_block', 'critical_unblock_low' ])
)
.catch(err => (
logger.warn({ trace: err.stack }, 'failed to sync app state')
))
)
}
const processSyncActions = (actions: ChatMutation[]) => { const processSyncActions = (actions: ChatMutation[]) => {
const updates: { [jid: string]: Partial<Chat> } = {} const updates: { [jid: string]: Partial<Chat> } = {}
const contactUpdates: { [jid: string]: Contact } = {} const contactUpdates: { [jid: string]: Contact } = {}
@@ -454,14 +468,7 @@ export const makeChatsSocket = (config: SocketConfig) => {
sendPresenceUpdate('available') sendPresenceUpdate('available')
fetchBlocklist() fetchBlocklist()
fetchPrivacySettings() fetchPrivacySettings()
mutationMutex.mutex( resyncMainAppState()
async() => {
await (
resyncAppState([ 'critical_block', 'critical_unblock_low' ])
.catch(err => logger.info({ trace: err.stack }, 'failed to sync app state'))
)
}
)
} }
}) })
@@ -478,5 +485,6 @@ export const makeChatsSocket = (config: SocketConfig) => {
updateBlockStatus, updateBlockStatus,
resyncAppState, resyncAppState,
chatModify, chatModify,
resyncMainAppState,
} }
} }