mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
perf: put main app state sync in transaction
This commit is contained in:
@@ -178,6 +178,10 @@ export const makeChatsSocket = (config: SocketConfig) => {
|
||||
const resyncAppStateInternal = async(collections: WAPatchName[], fromScratch: boolean = false, returnSnapshot: boolean = false) => {
|
||||
if(fromScratch) returnSnapshot = true
|
||||
|
||||
const totalMutations: ChatMutation[] = []
|
||||
|
||||
await authState.keys.transaction(
|
||||
async() => {
|
||||
const states = { } as { [T in WAPatchName]: LTHashState }
|
||||
for(const name of collections) {
|
||||
let state: LTHashState
|
||||
@@ -217,7 +221,6 @@ export const makeChatsSocket = (config: SocketConfig) => {
|
||||
})
|
||||
|
||||
const decoded = await extractSyncdPatches(result) // extract from binary node
|
||||
const totalMutations: ChatMutation[] = []
|
||||
for(const key in decoded) {
|
||||
const name = key as WAPatchName
|
||||
const { patches, snapshot } = decoded[name]
|
||||
@@ -241,6 +244,8 @@ export const makeChatsSocket = (config: SocketConfig) => {
|
||||
totalMutations.push(...newMutations)
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
processSyncActions(totalMutations)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user