From b0413e3c84471ce19b53474f4305c8fe1cba3959 Mon Sep 17 00:00:00 2001 From: Bodhish Thomas Date: Sun, 9 Jun 2024 23:35:23 +0530 Subject: [PATCH] Fix TypeError in NotificationsList Component --- src/Components/Notifications/NotificationsList.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Components/Notifications/NotificationsList.tsx b/src/Components/Notifications/NotificationsList.tsx index c9e6720e6ad..e34e7b5b06e 100644 --- a/src/Components/Notifications/NotificationsList.tsx +++ b/src/Components/Notifications/NotificationsList.tsx @@ -197,10 +197,16 @@ export default function NotificationsList({ const intialSubscriptionState = async () => { try { + if (!("serviceWorker" in navigator)) { + throw new Error("Service Worker is not supported in this browser."); + } const res = await request(routes.getUserPnconfig, { pathParams: { username: username }, }); const reg = await navigator.serviceWorker.ready; + if (!reg.pushManager) { + throw new Error("Push Manager is not available in this service worker."); + } const subscription = await reg.pushManager.getSubscription(); if (!subscription && !res.data?.pf_endpoint) { setIsSubscribed("NotSubscribed"); @@ -211,6 +217,7 @@ export default function NotificationsList({ } } catch (error) { Sentry.captureException(error); + setIsSubscribed("Error"); } };