Skip to content

Commit

Permalink
exposeFunctionIfAbsent - onLogoutEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
devlikepro committed Sep 25, 2024
1 parent 650e0cd commit 225ad02
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,15 +241,10 @@ class Client extends EventEmitter {
this.emit(Events.LOADING_SCREEN, percent, 'WhatsApp'); // Message is hardcoded as "WhatsApp" for now
}
});
const logoutCatchInjected = await this.pupPage.evaluate(() => {
return typeof window.onLogoutEvent !== 'undefined';
await exposeFunctionIfAbsent(this.pupPage, 'onLogoutEvent', async () => {
this.lastLoggedOut = true;
await this.pupPage.waitForNavigation({waitUntil: 'load', timeout: 5000}).catch((_) => _);
});
if (!logoutCatchInjected) {
await exposeFunctionIfAbsent(this.pupPage, 'onLogoutEvent', async () => {
this.lastLoggedOut = true;
await this.pupPage.waitForNavigation({waitUntil: 'load', timeout: 5000}).catch((_) => _);
});
}
await this.pupPage.evaluate(() => {
window.AuthStore.AppState.on('change:state', (_AppState, state) => { window.onAuthAppStateChangedEvent(state); });
window.AuthStore.AppState.on('change:hasSynced', () => { window.onAppStateHasSyncedEvent(); });
Expand Down

0 comments on commit 225ad02

Please sign in to comment.