mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
refactor!: cleaner message history sync
This is a breaking change, 1. three events (chats.set, contacts.set, messages.set) are now just one `messaging-history.set` event 2. no need to debounce for app state sync 3. added a new "conditional" chat update to allow for correct app state sync despite not having the chat available on hand
This commit is contained in:
@@ -98,21 +98,10 @@ const startSock = async() => {
|
||||
console.log('recv call event', events.call)
|
||||
}
|
||||
|
||||
// chat history received
|
||||
if(events['chats.set']) {
|
||||
const { chats, isLatest } = events['chats.set']
|
||||
console.log(`recv ${chats.length} chats (is latest: ${isLatest})`)
|
||||
}
|
||||
|
||||
// message history received
|
||||
if(events['messages.set']) {
|
||||
const { messages, isLatest } = events['messages.set']
|
||||
console.log(`recv ${messages.length} messages (is latest: ${isLatest})`)
|
||||
}
|
||||
|
||||
if(events['contacts.set']) {
|
||||
const { contacts, isLatest } = events['contacts.set']
|
||||
console.log(`recv ${contacts.length} contacts (is latest: ${isLatest})`)
|
||||
// history received
|
||||
if(events['messaging-history.set']) {
|
||||
const { chats, contacts, messages, isLatest } = events['messaging-history.set']
|
||||
console.log(`recv ${chats.length} chats, ${contacts.length} contacts, ${messages.length} msgs (is latest: ${isLatest})`)
|
||||
}
|
||||
|
||||
// received a new message
|
||||
|
||||
Reference in New Issue
Block a user