diff --git a/src/Tests/Tests.Groups.ts b/src/Tests/Tests.Groups.ts index b53a086..582e7ce 100644 --- a/src/Tests/Tests.Groups.ts +++ b/src/Tests/Tests.Groups.ts @@ -101,8 +101,11 @@ WAConnectionTest('Groups', (conn) => { } }) }) - await conn.groupRemove(gid, [testJid]) - await waitForEvent + const metadata = await conn.groupMetadata (gid) + if (metadata.participants.find(({id}) => id === testJid)) { + await conn.groupRemove(gid, [testJid]) + await waitForEvent + } conn.removeAllListeners ('group-participants-remove') }) it('should leave the group', async () => { diff --git a/src/WAConnection/4.Events.ts b/src/WAConnection/4.Events.ts index 9c7b914..e441f61 100644 --- a/src/WAConnection/4.Events.ts +++ b/src/WAConnection/4.Events.ts @@ -160,6 +160,8 @@ export class WAConnection extends Base { } /** inserts an empty chat into the DB */ protected async chatAdd (jid: string, name?: string) { + if (this.chats.get (jid)) return + const chat: WAChat = { jid: jid, t: unixTimestampSeconds(),