Skip to content

Commit

Permalink
Add code to unregister service worker if flag is not used
Browse files Browse the repository at this point in the history
  • Loading branch information
microbit-robert committed May 28, 2024
1 parent 6134ebd commit e35db80
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/simulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,17 @@ function initServiceWorker() {

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();
})
}
})
}

const fs = new FileSystem();
const board = createBoard(new Notifications(window.parent), fs);
window.addEventListener("message", createMessageListener(board));

0 comments on commit e35db80

Please sign in to comment.