diff options
| author | Henry Jameson <me@hjkos.com> | 2023-11-22 21:38:54 +0200 |
|---|---|---|
| committer | Henry Jameson <me@hjkos.com> | 2023-11-22 21:38:54 +0200 |
| commit | a5f09b726307367c31c0efdf365eb9b02a852eb5 (patch) | |
| tree | 9e71cb68b31a270f6e29ae43e6cba8d8dc46a7d0 /src/services/sw/sw.js | |
| parent | 33564d8ccc859a87580c27c832e9b2fd69361c84 (diff) | |
don't communicate with serviceworker if there's no support for it
Diffstat (limited to 'src/services/sw/sw.js')
| -rw-r--r-- | src/services/sw/sw.js | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/services/sw/sw.js b/src/services/sw/sw.js index 247eaf94..4516c813 100644 --- a/src/services/sw/sw.js +++ b/src/services/sw/sw.js @@ -98,12 +98,14 @@ export async function initServiceWorker (store) { } export async function showDesktopNotification (content) { + if (!isSWSupported) return 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 }) { + if (!isSWSupported) return const { active: sw } = await window.navigator.serviceWorker.getRegistration() if (!sw) return console.error('No serviceworker found!') if (id >= 0) { @@ -114,6 +116,7 @@ export async function closeDesktopNotification ({ id }) { } export async function updateFocus () { + if (!isSWSupported) return const { active: sw } = await window.navigator.serviceWorker.getRegistration() if (!sw) return console.error('No serviceworker found!') sw.postMessage({ type: 'updateFocus' }) |
