possible duplicate key fix

This commit is contained in:
Adhiraj
2020-09-06 12:18:30 +05:30
parent cb9d511400
commit 0a8312a81f
2 changed files with 7 additions and 2 deletions

View File

@@ -101,8 +101,11 @@ WAConnectionTest('Groups', (conn) => {
} }
}) })
}) })
await conn.groupRemove(gid, [testJid]) const metadata = await conn.groupMetadata (gid)
await waitForEvent if (metadata.participants.find(({id}) => id === testJid)) {
await conn.groupRemove(gid, [testJid])
await waitForEvent
}
conn.removeAllListeners ('group-participants-remove') conn.removeAllListeners ('group-participants-remove')
}) })
it('should leave the group', async () => { it('should leave the group', async () => {

View File

@@ -160,6 +160,8 @@ export class WAConnection extends Base {
} }
/** inserts an empty chat into the DB */ /** inserts an empty chat into the DB */
protected async chatAdd (jid: string, name?: string) { protected async chatAdd (jid: string, name?: string) {
if (this.chats.get (jid)) return
const chat: WAChat = { const chat: WAChat = {
jid: jid, jid: jid,
t: unixTimestampSeconds(), t: unixTimestampSeconds(),