connect fixes

This commit is contained in:
Adhiraj
2020-08-31 21:36:27 +05:30
parent 7d4f50c00d
commit c5fec0e6a3
2 changed files with 2 additions and 1 deletions

View File

@@ -314,6 +314,7 @@ export class WAConnection extends EventEmitter {
this.conn = null
this.phoneConnected = false
this.lastDisconnectReason = reason
this.lastSeen = null
if (reason === 'invalid_session' || reason === 'intentional') {
this.pendingRequests.forEach (({reject}) => reject(new Error('close')))

View File

@@ -71,7 +71,7 @@ export class WAConnection extends Base {
// determine whether reconnect should be used or not
const shouldUseReconnect = this.lastDisconnectReason !== DisconnectReason.replaced &&
this.lastDisconnectReason !== DisconnectReason.unknown &&
this.lastDisconnectReason !== DisconnectReason.intentional && this.user
this.lastDisconnectReason !== DisconnectReason.intentional && this.user?.jid
const reconnectID = shouldUseReconnect ? this.user.jid.replace ('@s.whatsapp.net', '@c.us') : null
const promise = Utils.promiseTimeout(timeoutMs, (resolve, reject) => {