[Dev] Fix errors caused my missing Service Worker on localhost for iOS (#1431)
This commit is contained in:
parent
3e8d87d436
commit
73883a6776
@ -332,7 +332,7 @@ export async function showNewMessageNotification({
|
|||||||
const icon = await getAvatar(chat);
|
const icon = await getAvatar(chat);
|
||||||
|
|
||||||
if (checkIfPushSupported()) {
|
if (checkIfPushSupported()) {
|
||||||
if (navigator.serviceWorker.controller) {
|
if (navigator.serviceWorker?.controller) {
|
||||||
// notify service worker about new message notification
|
// notify service worker about new message notification
|
||||||
navigator.serviceWorker.controller.postMessage({
|
navigator.serviceWorker.controller.postMessage({
|
||||||
type: 'newMessageNotification',
|
type: 'newMessageNotification',
|
||||||
@ -379,7 +379,7 @@ export async function showNewMessageNotification({
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function closeMessageNotifications(payload: { chatId: number; lastReadInboxMessageId?: number }) {
|
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({
|
navigator.serviceWorker.controller.postMessage({
|
||||||
type: 'closeMessageNotifications',
|
type: 'closeMessageNotifications',
|
||||||
payload,
|
payload,
|
||||||
@ -388,7 +388,7 @@ export function closeMessageNotifications(payload: { chatId: number; lastReadInb
|
|||||||
|
|
||||||
// Notify service worker that client is fully loaded
|
// Notify service worker that client is fully loaded
|
||||||
export function notifyClientReady() {
|
export function notifyClientReady() {
|
||||||
if (!navigator.serviceWorker.controller) return;
|
if (!navigator.serviceWorker?.controller) return;
|
||||||
navigator.serviceWorker.controller.postMessage({
|
navigator.serviceWorker.controller.postMessage({
|
||||||
type: 'clientReady',
|
type: 'clientReady',
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user