Skip to content

Commit

Permalink
fix: Fixed stuck state after logout
Browse files Browse the repository at this point in the history
  • Loading branch information
edgardmessias committed Mar 13, 2022
1 parent 880489e commit bb9695a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/api/layers/host.layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,19 @@ export class HostLayer {
);
}

if (isValidSessionToken(sessionToken)) {
const isValidToken = isValidSessionToken(sessionToken);
if (isValidToken) {
this.log('verbose', 'Injecting session token', { type: 'token' });
}

const hasUserDataDir = !!this.options?.puppeteerOptions?.userDataDir;

let clear = !hasUserDataDir || (hasUserDataDir && !isValidToken);

await initWhatsapp(
this.page,
sessionToken,
!this.options?.puppeteerOptions?.userDataDir,
clear,
this.options.whatsappVersion
);

Expand Down
6 changes: 6 additions & 0 deletions src/api/whatsapp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ export class Whatsapp extends BusinessLayer {
this.statusFind('desconnectedMobile', session);
} catch (error) {}
}

if (connected) {
await page.evaluate(() => localStorage.clear());
await page.reload();
}

connected = false;
}, 1000);
break;
Expand Down

0 comments on commit bb9695a

Please sign in to comment.