diff --git a/src/Tests/Tests.Misc.ts b/src/Tests/Tests.Misc.ts index bf06015..6ad4de9 100644 --- a/src/Tests/Tests.Misc.ts +++ b/src/Tests/Tests.Misc.ts @@ -117,6 +117,9 @@ WAConnectionTest('Misc', (conn) => { } }) it('should load a single message', async () => { + const loaded = await conn.loadMessage (testJid, '5A3FF17786EBCD0EF350') + assert.equal (loaded.key.id, '5A3FF17786EBCD0EF350') + const {messages} = await conn.loadMessages (testJid, 10) for (var message of messages) { const loaded = await conn.loadMessage (testJid, message.key.id) diff --git a/src/WAConnection/3.Connect.ts b/src/WAConnection/3.Connect.ts index b83bc76..cc9a96e 100644 --- a/src/WAConnection/3.Connect.ts +++ b/src/WAConnection/3.Connect.ts @@ -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' diff --git a/tsconfig.json b/tsconfig.json index f30ced1..b35aa38 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,5 +13,5 @@ "lib": ["es2019", "esnext.array"] }, "include": ["src/*/*.ts"], - "exclude": ["node_modules", "src/*/Tests.ts"] + "exclude": ["node_modules", "src/Tests/*"] }