Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions packages/client/components/client/Controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,7 @@ class Lifecycle {

private dispose() {
if (this.client) {
this.client.events.removeAllListeners();
this.client.removeAllListeners();
this.client.events.disconnect();
this.client.logout();
}

this.client = new Client({
Expand Down Expand Up @@ -599,7 +597,7 @@ export default class ClientController {

logout() {
this.state.settings.resetNotificationsState();
killServiceWorkerSubscription(this.getCurrentClient());
killServiceWorkerSubscription(this.getCurrentClient(), true);
this.state.auth.removeSession();
this.lifecycle.transition({
type: TransitionType.Logout,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,10 @@ function arrayBufferToBase64URL(buffer: ArrayBuffer): string {
}

/** Exported for the client controller. Don't use this unless you have to. */
export async function killServiceWorkerSubscription(client: Client) {
export async function killServiceWorkerSubscription(
client: Client,
loggingOut?: boolean,
) {
if (IS_DEV) {
console.log("Skipping killing push worker in dev.");
return;
Expand All @@ -183,6 +186,6 @@ export async function killServiceWorkerSubscription(client: Client) {
if (!registration) return;
const subscription = await registration.pushManager.getSubscription();
if (await subscription?.unsubscribe()) {
await client.api.post("/push/unsubscribe");
if (!loggingOut) await client.api.post("/push/unsubscribe");
}
}
Loading