fix: logout without pwa (#528)
This commit is contained in:
parent
cd268c9bc7
commit
6037700197
@ -65,8 +65,11 @@ async function loginTo(user?: Omit<UserLogin, 'account'> & { account?: AccountCr
|
|||||||
const [me, instance, pushSubscription] = await Promise.all([
|
const [me, instance, pushSubscription] = await Promise.all([
|
||||||
masto.accounts.verifyCredentials(),
|
masto.accounts.verifyCredentials(),
|
||||||
masto.instances.fetch(),
|
masto.instances.fetch(),
|
||||||
// we get 404 response instead empty data
|
// if PWA is not enabled, don't get push subscription
|
||||||
masto.pushSubscriptions.fetch().catch(() => Promise.resolve(undefined)),
|
useRuntimeConfig().public.pwaEnabled
|
||||||
|
// we get 404 response instead empty data
|
||||||
|
? masto.pushSubscriptions.fetch().catch(() => Promise.resolve(undefined))
|
||||||
|
: Promise.resolve(undefined),
|
||||||
])
|
])
|
||||||
|
|
||||||
user.account = me
|
user.account = me
|
||||||
@ -104,8 +107,10 @@ export async function removePushNotificationData(user: UserLogin, fromSWPushMana
|
|||||||
// clear push notification policy
|
// clear push notification policy
|
||||||
delete useLocalStorage<PushNotificationPolicy>(STORAGE_KEY_NOTIFICATION_POLICY, {}).value[acct]
|
delete useLocalStorage<PushNotificationPolicy>(STORAGE_KEY_NOTIFICATION_POLICY, {}).value[acct]
|
||||||
|
|
||||||
|
const pwaEnabled = useRuntimeConfig().public.pwaEnabled
|
||||||
|
|
||||||
// we remove the sw push manager if required and there are no more accounts with subscriptions
|
// we remove the sw push manager if required and there are no more accounts with subscriptions
|
||||||
if (fromSWPushManager && (users.value.length === 0 || users.value.every(u => !u.pushSubscription))) {
|
if (pwaEnabled && fromSWPushManager && (users.value.length === 0 || users.value.every(u => !u.pushSubscription))) {
|
||||||
// clear sw push subscription
|
// clear sw push subscription
|
||||||
try {
|
try {
|
||||||
const registration = await navigator.serviceWorker.ready
|
const registration = await navigator.serviceWorker.ready
|
||||||
@ -120,7 +125,7 @@ export async function removePushNotificationData(user: UserLogin, fromSWPushMana
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function removePushNotifications(user: UserLogin) {
|
export async function removePushNotifications(user: UserLogin) {
|
||||||
if (!useRuntimeConfig().public.pwaEnabled || !user.pushSubscription)
|
if (!user.pushSubscription)
|
||||||
return
|
return
|
||||||
|
|
||||||
// unsubscribe push notifications
|
// unsubscribe push notifications
|
||||||
|
Loading…
Reference in New Issue
Block a user