diff --git a/app/javascript/dashboard/helper/pushHelper.js b/app/javascript/dashboard/helper/pushHelper.js index d614cfb8d..2580c17b8 100644 --- a/app/javascript/dashboard/helper/pushHelper.js +++ b/app/javascript/dashboard/helper/pushHelper.js @@ -2,13 +2,6 @@ import NotificationSubscriptions from '../api/notificationSubscription'; import auth from '../api/auth'; import { useAlert } from 'dashboard/composables'; -/** - * Request the service worker to prefetch all assets in the manifest. - */ -const prefetchAssets = () => { - navigator.serviceWorker?.controller?.postMessage({ type: 'PREFETCH_ASSETS' }); -}; - export const verifyServiceWorkerExistence = (callback = () => {}) => { if (!('serviceWorker' in navigator)) { // Service Worker isn't supported on this browser, disable or hide UI. @@ -41,14 +34,6 @@ export const verifyServiceWorkerExistence = (callback = () => {}) => { }); }); - // Trigger asset prefetch during idle time - if ('requestIdleCallback' in window) { - window.requestIdleCallback(() => prefetchAssets(), { timeout: 5000 }); - } else { - // Fallback: prefetch after 3 seconds - setTimeout(prefetchAssets, 3000); - } - callback(registration); }) .catch(registrationError => { diff --git a/app/javascript/service-worker/sw-runtime.js b/app/javascript/service-worker/sw-runtime.js index 906c8962a..83e9d1ab3 100644 --- a/app/javascript/service-worker/sw-runtime.js +++ b/app/javascript/service-worker/sw-runtime.js @@ -122,12 +122,7 @@ self.addEventListener('install', () => self.skipWaiting()); self.addEventListener('activate', event => { event.waitUntil( - Promise.all([ - // Clean up stale assets not in current manifest - cleanupStaleAssets(), - // Take control of all clients - self.clients.claim(), - ]) + Promise.all([cleanupStaleAssets(), prefetchAssets(), self.clients.claim()]) ); }); @@ -164,10 +159,3 @@ async function cleanupStaleAssets() { await Promise.all(deletions); } - -self.addEventListener('message', async event => { - if (event.data?.type === 'PREFETCH_ASSETS') { - await prefetchAssets(); - event.ports[0]?.postMessage({ type: 'PREFETCH_COMPLETE' }); - } -});