From acc8e864fa1950a8e1feb7e0c0b42b3128c9edac Mon Sep 17 00:00:00 2001 From: Adhiraj Date: Mon, 31 Aug 2020 10:50:02 +0530 Subject: [PATCH] Update 3.Connect.ts --- src/WAConnection/3.Connect.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/WAConnection/3.Connect.ts b/src/WAConnection/3.Connect.ts index 6205e7b..7306e55 100644 --- a/src/WAConnection/3.Connect.ts +++ b/src/WAConnection/3.Connect.ts @@ -243,7 +243,11 @@ export class WAConnection extends Base { } await delay + try { + // if an external connect causes the connection to be open + if (this.state === 'open') break + const shouldUseReconnect = this.lastDisconnectReason !== DisconnectReason.replaced && this.lastDisconnectReason !== DisconnectReason.unknown && this.user const reconnectID = shouldUseReconnect ? this.user.jid.replace ('@s.whatsapp.net', '@c.us') : null