move serviceworker registration to separate module
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Philipp Dormann 2021-01-10 11:42:30 +01:00
parent 7cf2ffce2d
commit 8f25a874cb
2 changed files with 16 additions and 19 deletions

View File

@ -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();
</script>
<style>
.bg-gray-900 {
background-color: #121317;
}
</style>
<Route>
{#if $router.path === '/forgot_password'}
<Route path="/forgot_password">

14
src/swmodule.js Normal file
View File

@ -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}`);
}
);
});
}
};