possibly more reliable connect

This commit is contained in:
Adhiraj
2020-08-25 18:33:43 +05:30
parent aac613094c
commit 59df353746
3 changed files with 9 additions and 4 deletions

View File

@@ -36,10 +36,12 @@ export class WAConnection extends Base {
})
try {
await promise
const tasks = [promise]
const waitForChats = typeof options?.waitForChats === 'undefined' ? true : options?.waitForChats
waitForChats && await this.receiveChatsAndContacts(options?.timeoutMs, true)
if (waitForChats) tasks.push (this.receiveChatsAndContacts(options?.timeoutMs, true))
await Promise.all (tasks)
this.phoneConnected = true
this.state = 'open'