diff --git a/src/App.svelte b/src/App.svelte index e5b38bb7..d0215433 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -47,28 +47,11 @@ import { OpenAPI, AuthService } from "@odit/lfk-client-js"; import UserDetail from "./components/UserDetail.svelte"; OpenAPI.BASE = config.baseurl; + import { register as registerSW } from "./swmodule"; store.init(); - - if ("serviceWorker" in navigator) { - window.addEventListener("load", () => { - navigator.serviceWorker.register("/sw.js").then( - (registration) => { - // console.log(`sw successful with scope: ${registration.scope}`); - }, - (err) => { - // console.log(`sw failed: ${err}`); - } - ); - }); - } + // registerSW(); - - {#if $router.path === '/forgot_password'} diff --git a/src/swmodule.js b/src/swmodule.js new file mode 100644 index 00000000..c91c19d5 --- /dev/null +++ b/src/swmodule.js @@ -0,0 +1,14 @@ +export const register = () => { + if ('serviceWorker' in navigator) { + window.addEventListener('load', () => { + navigator.serviceWorker.register('/sw.js').then( + (registration) => { + // console.log(`sw successful with scope: ${registration.scope}`); + }, + (err) => { + // console.log(`sw failed: ${err}`); + } + ); + }); + } +};