From 02187b1158724047c43d43672ded86a8e458dfce Mon Sep 17 00:00:00 2001
From: Thomas Citharel <tcit@tcit.fr>
Date: Wed, 21 Jul 2021 12:11:59 +0200
Subject: [PATCH] Fix Notifications page broken page on Safari

Closes #772

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
---
 js/src/services/push-subscription.ts    | 2 +-
 js/src/views/Settings/Notifications.vue | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/js/src/services/push-subscription.ts b/js/src/services/push-subscription.ts
index 02195fdd6..ef4734b6a 100644
--- a/js/src/services/push-subscription.ts
+++ b/js/src/services/push-subscription.ts
@@ -50,7 +50,7 @@ export async function unsubscribeUserToPush(): Promise<string | undefined> {
   console.log("performing unsubscribeUserToPush");
   const registration = await navigator.serviceWorker.ready;
   console.log("found registration", registration);
-  const subscription = await registration.pushManager.getSubscription();
+  const subscription = await registration.pushManager?.getSubscription();
   console.log("found subscription", subscription);
   if (subscription && (await subscription?.unsubscribe()) === true) {
     console.log("done unsubscription");
diff --git a/js/src/views/Settings/Notifications.vue b/js/src/views/Settings/Notifications.vue
index d3eca06e3..8a4962fee 100644
--- a/js/src/views/Settings/Notifications.vue
+++ b/js/src/views/Settings/Notifications.vue
@@ -715,7 +715,7 @@ export default class Notifications extends Vue {
   private async isSubscribed(): Promise<boolean> {
     if (!("serviceWorker" in navigator)) return Promise.resolve(false);
     const registration = await navigator.serviceWorker.getRegistration();
-    return (await registration?.pushManager.getSubscription()) != null;
+    return (await registration?.pushManager?.getSubscription()) != null;
   }
 
   private async deleteFeedToken(token: string): Promise<void> {