From b56e793a15d1228bb2d08535fd74a9d58ad9de40 Mon Sep 17 00:00:00 2001 From: Kris Hu Date: Mon, 18 Aug 2025 20:50:39 +0800 Subject: [PATCH] fix(noti): try-catch all badge API calls --- src/app/pages/client/ClientNonUIFeatures.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/app/pages/client/ClientNonUIFeatures.tsx b/src/app/pages/client/ClientNonUIFeatures.tsx index 9acb90b33..9f3a941d3 100644 --- a/src/app/pages/client/ClientNonUIFeatures.tsx +++ b/src/app/pages/client/ClientNonUIFeatures.tsx @@ -81,15 +81,15 @@ function FaviconUpdater() { } try { navigator.setAppBadge(total); + if (usePushNotifications && total === 0) { + registration.getNotifications() + .then((pushNotifications) => pushNotifications + .forEach((pushNotification) => pushNotification.close())); + navigator.clearAppBadge(); + } } catch (e) { // Likely Firefox/Gecko-based and doesn't support badging API } - if (usePushNotifications && total === 0) { - registration.getNotifications() - .then((pushNotifications) => pushNotifications - .forEach((pushNotification) => pushNotification.close())); - navigator.clearAppBadge(); - } }, [roomToUnread, usePushNotifications, registration]); return null;