refactor: process sync actions out of socket

This commit is contained in:
Adhiraj Singh
2022-03-29 14:16:51 +05:30
parent ab9b232838
commit ec6e904db4
4 changed files with 87 additions and 72 deletions

View File

@@ -27,6 +27,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
relayMessage,
sendReceipt,
resyncMainAppState,
emitEventsFromMap,
} = sock
/** this mutex ensures that the notifications (receipts, messages etc.) are processed in order */
@@ -131,12 +132,6 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
})
}
const emitEventsFromMap = (map: Partial<BaileysEventMap<any>>) => {
for(const key in map) {
ev.emit(key as any, map[key])
}
}
const processMessageLocal = async(message: proto.IWebMessageInfo) => {
const meId = authState.creds.me!.id
// send ack for history message