Fix initial-data-received called multiple times

The latest android version has messages with the last: true flag set on all messages, causing incorrect events being fired off. This update creates a timeout that fires off the initial-data-received 2500ms after the last messages received.

This may not be as accurate in production but will be better than the current version
This commit is contained in:
Adhiraj Singh
2021-02-04 19:04:50 +05:30
parent 63dd136afa
commit dfaeef0db1
7 changed files with 57 additions and 41 deletions

View File

@@ -25,6 +25,9 @@ async function example() {
conn.on('contacts-received', () => {
console.log(`you have ${Object.keys(conn.contacts).length} contacts`)
})
conn.on('initial-data-received', () => {
console.log('received all initial messages')
})
// loads the auth file credentials if present
/* Note: one can take this auth_info.json file and login again from any computer without having to scan the QR code,