From 07b1ed74fc1ca1fb3414d22082fccaf63d004441 Mon Sep 17 00:00:00 2001 From: Matt Hillsdon <44397098+microbit-matt-hillsdon@users.noreply.github.com> Date: Wed, 29 May 2024 16:17:08 +0100 Subject: [PATCH] Change the SW clean-up (#116) We can just remove the SW for our scope. --- src/simulator.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/simulator.ts b/src/simulator.ts index 7b12913..7410722 100644 --- a/src/simulator.ts +++ b/src/simulator.ts @@ -47,13 +47,10 @@ if ("serviceWorker" in navigator) { if (flags.sw) { initServiceWorker(); } else { - navigator.serviceWorker.getRegistrations().then((registrations) => { - if (registrations.length > 0) { - // We should only have one service worker to unregister. - registrations[0].unregister().then(() => { - window.location.reload(); - }); - } + navigator.serviceWorker.getRegistration().then((registration) => { + registration?.unregister().then(() => { + window.location.reload(); + }); }); } }