From cf9156b4141fe7bffdd72de2aa9f8e915e57175b Mon Sep 17 00:00:00 2001 From: Chewbacca Date: Wed, 11 Jan 2023 14:55:52 -0500 Subject: [PATCH] Refactor conditional --- app/soapbox/actions/notifications.ts | 2 +- app/soapbox/features/ui/index.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/soapbox/actions/notifications.ts b/app/soapbox/actions/notifications.ts index e5ff47cbd..972735e54 100644 --- a/app/soapbox/actions/notifications.ts +++ b/app/soapbox/actions/notifications.ts @@ -108,7 +108,7 @@ const updateNotificationsQueue = (notification: APIEntity, intlMessages: Record< // Desktop notifications try { // eslint-disable-next-line compat/compat - const isNotificationsEnabled = typeof window.Notification !== 'undefined' && Notification.permission === 'granted'; + const isNotificationsEnabled = window.Notification?.permission === 'granted'; if (showAlert && !filtered && isNotificationsEnabled) { const title = new IntlMessageFormat(intlMessages[`notification.${notification.type}`], intlLocale).format({ name: notification.account.display_name.length > 0 ? notification.account.display_name : notification.account.username }); diff --git a/app/soapbox/features/ui/index.tsx b/app/soapbox/features/ui/index.tsx index a5a29ec93..319ae539f 100644 --- a/app/soapbox/features/ui/index.tsx +++ b/app/soapbox/features/ui/index.tsx @@ -472,7 +472,7 @@ const UI: React.FC = ({ children }) => { navigator.serviceWorker.addEventListener('message', handleServiceWorkerPostMessage); } - if (typeof window.Notification !== 'undefined' && Notification.permission === 'default') { + if (window.Notification?.permission === 'default') { window.setTimeout(() => Notification.requestPermission(), 120 * 1000); }