diff options
| author | Owen Jacobson <owen@grimoire.ca> | 2025-11-10 20:51:11 -0500 |
|---|---|---|
| committer | Owen Jacobson <owen@grimoire.ca> | 2025-11-10 20:51:11 -0500 |
| commit | 91c33501a315abe04aeed54aa27388ce0ad241ce (patch) | |
| tree | 56b7be71cc9811f86f5e59e02358d24bad57c1d2 | |
| parent | 73d79002fe6018ab12457b37bdaeb76ff2800213 (diff) | |
Push messaging fixes:
* Remove push subscriptions on logout, to trigger a resubscription when logging back in.
* Don't try to call `this.push` when there's no `this` to have a `push` on.
| -rw-r--r-- | ui/lib/session.svelte.js | 7 | ||||
| -rw-r--r-- | ui/routes/(app)/me/+page.svelte | 3 |
2 files changed, 9 insertions, 1 deletions
diff --git a/ui/lib/session.svelte.js b/ui/lib/session.svelte.js index cd41aa4..74508ea 100644 --- a/ui/lib/session.svelte.js +++ b/ui/lib/session.svelte.js @@ -145,7 +145,12 @@ async function bootOrNavigate(navigateTo) { } catch (err) { switch (true) { case err instanceof api.LoggedOut: - await this.push.unsubscribe(); + // Can't use `Push` state manager here as it requires boot, which we just failed to do. + const sw = await navigator.serviceWorker.ready; + const subscription = await sw.pushManager.getSubscription(); + if (subscription !== null) { + await subscription.unsubscribe(); + } await navigateTo('/login'); break; case err instanceof api.SetupRequired: diff --git a/ui/routes/(app)/me/+page.svelte b/ui/routes/(app)/me/+page.svelte index a21d160..afdcbe4 100644 --- a/ui/routes/(app)/me/+page.svelte +++ b/ui/routes/(app)/me/+page.svelte @@ -17,12 +17,15 @@ async function logOut() { const response = await api.logOut(); if (200 <= response.status && response.status < 300) { + await session.push.unsubscribe(); await goto('/login'); } } async function changePassword(currentPassword, newPassword) { await api.changePassword(currentPassword, newPassword); + await session.push.unsubscribe(); + await session.push.resubscribe(); } async function createInvite() { |
