mirror of
https://github.com/cheveguerra/whatsapp-web.js.git
synced 2026-04-20 20:49:14 +00:00
fix: only emit disconnected event on navigation when state is PAIRING (#1169)
This commit is contained in:
@@ -430,11 +430,13 @@ class Client extends EventEmitter {
|
|||||||
*/
|
*/
|
||||||
this.emit(Events.READY);
|
this.emit(Events.READY);
|
||||||
|
|
||||||
// Disconnect when navigating away
|
// Disconnect when navigating away when in PAIRING state (detect logout)
|
||||||
// Because WhatsApp Web now reloads when logging out from the device, this also covers that case
|
|
||||||
this.pupPage.on('framenavigated', async () => {
|
this.pupPage.on('framenavigated', async () => {
|
||||||
this.emit(Events.DISCONNECTED, 'NAVIGATION');
|
const appState = await this.getState();
|
||||||
await this.destroy();
|
if(appState === WAState.PAIRING) {
|
||||||
|
this.emit(Events.DISCONNECTED, 'NAVIGATION');
|
||||||
|
await this.destroy();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user