diff --git a/composables/users.ts b/composables/users.ts index 64e4479a..ffe98b25 100644 --- a/composables/users.ts +++ b/composables/users.ts @@ -65,8 +65,11 @@ async function loginTo(user?: Omit & { account?: AccountCr const [me, instance, pushSubscription] = await Promise.all([ masto.accounts.verifyCredentials(), masto.instances.fetch(), - // we get 404 response instead empty data - masto.pushSubscriptions.fetch().catch(() => Promise.resolve(undefined)), + // if PWA is not enabled, don't get push subscription + useRuntimeConfig().public.pwaEnabled + // we get 404 response instead empty data + ? masto.pushSubscriptions.fetch().catch(() => Promise.resolve(undefined)) + : Promise.resolve(undefined), ]) user.account = me @@ -104,8 +107,10 @@ export async function removePushNotificationData(user: UserLogin, fromSWPushMana // clear push notification policy delete useLocalStorage(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 - 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 try { const registration = await navigator.serviceWorker.ready @@ -120,7 +125,7 @@ export async function removePushNotificationData(user: UserLogin, fromSWPushMana } export async function removePushNotifications(user: UserLogin) { - if (!useRuntimeConfig().public.pwaEnabled || !user.pushSubscription) + if (!user.pushSubscription) return // unsubscribe push notifications