Major redo with respect to chats/contacts -- read desc

Waiting for chats & contacts is hella unreliable, so I've put them as events
1. receive chats via the `chats-received` event. If new chats are found, the flag for that is sent as well
2. receive contacts via the `contacts-received` event
3. When WA sends older messages, the `chats-update` or `chat-update` event is triggered
4. Baileys keeps track of all the changed conversations between connects

Connects almost always take less than 10 seconds!
This commit is contained in:
Adhiraj Singh
2020-11-13 23:15:16 +05:30
parent eace0c1795
commit 6d02d405a7
10 changed files with 232 additions and 196 deletions

View File

@@ -76,7 +76,13 @@ export class WAConnection extends Base {
this.emit ('connection-validated', this.user)
if (this.loadProfilePicturesForChatsAutomatically) {
const response = await this.query({ json: ['query', 'ProfilePicThumb', this.user.jid], waitForOpen: false, expect200: false, requiresPhoneConnection: false, startDebouncedTimeout: true })
const response = await this.query({
json: ['query', 'ProfilePicThumb', this.user.jid],
waitForOpen: false,
expect200: false,
requiresPhoneConnection: false,
startDebouncedTimeout: true
})
this.user.imgUrl = response?.eurl || ''
}