logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe git clone https://hacktivis.me/git/pleroma-fe.git
commit: 33564d8ccc859a87580c27c832e9b2fd69361c84
parent 92685e37b61d27cfd964c000f45331535d97de39
Author: Henry Jameson <me@hjkos.com>
Date:   Wed, 22 Nov 2023 13:17:55 +0200

handle no sw registration gracefully

Diffstat:

Msrc/services/sw/sw.js3+++
1 file changed, 3 insertions(+), 0 deletions(-)

diff --git a/src/services/sw/sw.js b/src/services/sw/sw.js @@ -99,11 +99,13 @@ export async function initServiceWorker (store) { export async function showDesktopNotification (content) { const { active: sw } = await window.navigator.serviceWorker.getRegistration() + if (!sw) return console.error('No serviceworker found!') sw.postMessage({ type: 'desktopNotification', content }) } export async function closeDesktopNotification ({ id }) { const { active: sw } = await window.navigator.serviceWorker.getRegistration() + if (!sw) return console.error('No serviceworker found!') if (id >= 0) { sw.postMessage({ type: 'desktopNotificationClose', content: { id } }) } else { @@ -113,6 +115,7 @@ export async function closeDesktopNotification ({ id }) { export async function updateFocus () { const { active: sw } = await window.navigator.serviceWorker.getRegistration() + if (!sw) return console.error('No serviceworker found!') sw.postMessage({ type: 'updateFocus' }) }