From 897f6ca6368c73b9797fffe49f2408d5c1e0e363 Mon Sep 17 00:00:00 2001 From: Alexandros Tzimas Date: Thu, 19 Dec 2024 10:15:54 +0200 Subject: [PATCH] Only unregister the WS worker This is done so that a walrus site can still use its' own service worker. --- portal/server/inject_unregister_sw_script.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/portal/server/inject_unregister_sw_script.ts b/portal/server/inject_unregister_sw_script.ts index fc9b16f..2122578 100644 --- a/portal/server/inject_unregister_sw_script.ts +++ b/portal/server/inject_unregister_sw_script.ts @@ -20,8 +20,10 @@ export async function inject_unregister_service_worker_script(response: Response console.log('Unregistering the walrus sites service-worker!'); navigator.serviceWorker.getRegistrations().then(registrations => { registrations.forEach(registration => { - registration.unregister(); - console.log('Service worker successfully unregistered.'); + if (registration.scope.includes('walrus-sites-sw')) { + registration.unregister(); + console.log('Service worker successfully unregistered.'); + } }); }); }