From 73883a67765925f294d5b11788cad5f1d696a0d7 Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Fri, 10 Sep 2021 20:32:55 +0300 Subject: [PATCH] [Dev] Fix errors caused my missing Service Worker on localhost for iOS (#1431) --- src/util/notifications.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/util/notifications.ts b/src/util/notifications.ts index 270bf818b..f31ef5181 100644 --- a/src/util/notifications.ts +++ b/src/util/notifications.ts @@ -332,7 +332,7 @@ export async function showNewMessageNotification({ const icon = await getAvatar(chat); if (checkIfPushSupported()) { - if (navigator.serviceWorker.controller) { + if (navigator.serviceWorker?.controller) { // notify service worker about new message notification navigator.serviceWorker.controller.postMessage({ type: 'newMessageNotification', @@ -379,7 +379,7 @@ export async function showNewMessageNotification({ } export function closeMessageNotifications(payload: { chatId: number; lastReadInboxMessageId?: number }) { - if (IS_TEST || !navigator.serviceWorker.controller) return; + if (IS_TEST || !navigator.serviceWorker?.controller) return; navigator.serviceWorker.controller.postMessage({ type: 'closeMessageNotifications', payload, @@ -388,7 +388,7 @@ export function closeMessageNotifications(payload: { chatId: number; lastReadInb // Notify service worker that client is fully loaded export function notifyClientReady() { - if (!navigator.serviceWorker.controller) return; + if (!navigator.serviceWorker?.controller) return; navigator.serviceWorker.controller.postMessage({ type: 'clientReady', });