diff options
author | Jakob Stendahl <jakob.stendahl@outlook.com> | 2021-02-09 11:12:01 +0100 |
---|---|---|
committer | Jakob Stendahl <jakob.stendahl@outlook.com> | 2021-02-09 11:12:01 +0100 |
commit | 4998be1a33965a7ad74ce90de255d6617af16f38 (patch) | |
tree | 0d73806f6e8fb586cc815993d6a96758007dc26a /src/js | |
parent | df58b29a84fe482cbc2a1d6af385c7cead055bcc (diff) | |
download | hoverbit-ble-4998be1a33965a7ad74ce90de255d6617af16f38.tar.gz hoverbit-ble-4998be1a33965a7ad74ce90de255d6617af16f38.zip |
:wrench: Try another fix for service worker
Diffstat (limited to 'src/js')
-rw-r--r-- | src/js/main.js | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/src/js/main.js b/src/js/main.js index 1c26af9..07d105c 100644 --- a/src/js/main.js +++ b/src/js/main.js @@ -4,29 +4,30 @@ import hoverControlModule from './hoverControlModule'; import { notif_alert, notif_warn, notif_info, notif_success } from './notification'; let sw = "service-worker.js"; -//if (navigator.serviceWorker) { -// navigator.serviceWorker.register(sw, {scope: '/hoverbit-ble/'}); -//} -navigator.serviceWorker.register( - sw, {scope: '/hoverbit-ble/'} -).then(registration => { - registration.onupdatefound = () => { - const installingWorker = registration.installing; - if (installingWorker == null) { return; } - installingWorker.onstatechange = () => { - if (installingWorker.state === "installed") { - if (navigator.serviceWorker.controller) { - notif_info("New content is available, relaunch the app to install it."); - } else { - notif_success("Content is cached for offline use."); +if (navigator.serviceWorker) { + // navigator.serviceWorker.register(sw, {scope: '/hoverbit-ble/'}); + //} + navigator.serviceWorker.register( + sw, {scope: '/hoverbit-ble/'} + ).then(registration => { + registration.onupdatefound = () => { + const installingWorker = registration.installing; + if (installingWorker == null) { return; } + installingWorker.onstatechange = () => { + if (installingWorker.state === "installed") { + if (navigator.serviceWorker.controller) { + notif_info("New content is available, relaunch the app to install it."); + } else { + notif_success("Content is cached for offline use."); + } } - } + }; }; - }; -}).catch(error => { - notif_alert("Could not install service worker..."); - console.error("Error during service worker registration:", error); -}); + }).catch(error => { + notif_alert("Could not install service worker..."); + console.error("Error during service worker registration:", error); + }); +} document.getElementById("btn_ignore_landscape_warning").addEventListener("click", () => { document.body.classList.add("ignore-landscape-warning"); |