mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
update disconnect reason for reconnect
This commit is contained in:
@@ -66,11 +66,6 @@ export class WAConnection extends Base {
|
|||||||
let cancel: () => void
|
let cancel: () => void
|
||||||
const task = new Promise((resolve, reject) => {
|
const task = new Promise((resolve, reject) => {
|
||||||
cancel = () => reject (CancelledError())
|
cancel = () => reject (CancelledError())
|
||||||
// determine whether reconnect should be used or not
|
|
||||||
const shouldUseReconnect = this.lastDisconnectReason !== DisconnectReason.replaced &&
|
|
||||||
this.lastDisconnectReason !== DisconnectReason.unknown &&
|
|
||||||
this.lastDisconnectReason !== DisconnectReason.intentional &&
|
|
||||||
this.user?.jid
|
|
||||||
|
|
||||||
const checkIdleTime = () => {
|
const checkIdleTime = () => {
|
||||||
this.debounceTimeout && clearTimeout (this.debounceTimeout)
|
this.debounceTimeout && clearTimeout (this.debounceTimeout)
|
||||||
@@ -81,7 +76,10 @@ export class WAConnection extends Base {
|
|||||||
clearTimeout (this.debounceTimeout)
|
clearTimeout (this.debounceTimeout)
|
||||||
this.conn.removeEventListener ('message', checkIdleTime)
|
this.conn.removeEventListener ('message', checkIdleTime)
|
||||||
}
|
}
|
||||||
|
// determine whether reconnect should be used or not
|
||||||
|
const shouldUseReconnect = (this.lastDisconnectReason === DisconnectReason.close ||
|
||||||
|
this.lastDisconnectReason === DisconnectReason.lost) &&
|
||||||
|
this.user?.jid
|
||||||
const reconnectID = shouldUseReconnect && this.user.jid.replace ('@s.whatsapp.net', '@c.us')
|
const reconnectID = shouldUseReconnect && this.user.jid.replace ('@s.whatsapp.net', '@c.us')
|
||||||
|
|
||||||
this.conn = new WS(WS_URL, null, {
|
this.conn = new WS(WS_URL, null, {
|
||||||
|
|||||||
Reference in New Issue
Block a user