From e11699597e02ce8e0e7c3fc6569eeff95deb349a Mon Sep 17 00:00:00 2001 From: ditatompel Date: Sun, 5 May 2024 14:25:01 +0700 Subject: [PATCH] Disable service worker --- frontend/src/lib/components/Footer.svelte | 38 +---------- frontend/src/routes/(front)/+layout.svelte | 76 ---------------------- 2 files changed, 3 insertions(+), 111 deletions(-) diff --git a/frontend/src/lib/components/Footer.svelte b/frontend/src/lib/components/Footer.svelte index 5d5f914..ca3e7af 100644 --- a/frontend/src/lib/components/Footer.svelte +++ b/frontend/src/lib/components/Footer.svelte @@ -1,42 +1,10 @@ - -
diff --git a/frontend/src/routes/(front)/+layout.svelte b/frontend/src/routes/(front)/+layout.svelte index dd1d263..e356060 100644 --- a/frontend/src/routes/(front)/+layout.svelte +++ b/frontend/src/routes/(front)/+layout.svelte @@ -9,17 +9,13 @@ Modal, Drawer, initializeStores, - getToastStore, storePopup // PopUps } from '@skeletonlabs/skeleton'; - import { dev, browser } from '$app/environment'; import { MainNav, MobileDrawer } from '$lib/components/navigation'; import Footer from '$lib/components/Footer.svelte'; initializeStores(); - const toastStore = getToastStore(); - // popups storePopup.set({ computePosition, autoUpdate, offset, shift, flip, arrow }); @@ -69,9 +65,6 @@ if (typeof page.data.meta.article === 'object') { meta.article.author = page.data.meta.article.author ?? ''; } - // if (!dev) { - // promotionEnabled.set(page.data.promotionEnabled ?? false); - // } } }); @@ -90,65 +83,6 @@ // elemPage.scrollTop = 0; // } }); - - if (browser) { - /* Service Worker */ - /** @type {any} */ - let newWorker; - - if ('serviceWorker' in navigator) { - navigator.serviceWorker - .register('/service-worker.js', { - type: dev ? 'module' : 'classic' - }) - .then((reg) => { - reg.addEventListener('updatefound', () => { - console.log('SW Update found'); - // An updated service worker has appeared in reg.installing! - newWorker = reg.installing; - - newWorker.addEventListener('statechange', () => { - // Has service worker state changed? - switch (newWorker.state) { - case 'installed': - // There is a new service worker available, show the notification - if (navigator.serviceWorker.controller) { - const notifUpdateSw = { - message: 'New version avaiable for this site is available.', - autohide: false, - action: { - label: 'Reload', - response: () => window.location.reload() - } - }; - toastStore.trigger(notifUpdateSw); - // localStorage.clear(); - // sessionStorage.clear(); - newWorker.postMessage({ action: 'skipWaiting' }); - } - break; - } - }); - }); - }) - .catch((err) => { - console.log('error with service worker', err); - }); - - /** @type {any} */ - let refreshing; - // The event listener that is fired when the service worker updates - // Here we reload the page - navigator.serviceWorker.addEventListener('controllerchange', function () { - if (refreshing) { - // console.log('refreshing'); - return; - } - // window.location.reload(); - refreshing = true; - }); - } - } @@ -191,16 +125,6 @@
- - - - - - - - - -