Skip to content

Commit e35db80

Browse files
Add code to unregister service worker if flag is not used
1 parent 6134ebd commit e35db80

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Diff for: src/simulator.ts

+10
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,17 @@ function initServiceWorker() {
5151

5252
if (flags.sw) {
5353
initServiceWorker();
54+
} else {
55+
navigator.serviceWorker.getRegistrations().then(registrations => {
56+
if (registrations.length > 0) {
57+
// We should only have one service worker to unregister.
58+
registrations[0].unregister().then(() => {
59+
window.location.reload();
60+
})
61+
}
62+
})
5463
}
64+
5565
const fs = new FileSystem();
5666
const board = createBoard(new Notifications(window.parent), fs);
5767
window.addEventListener("message", createMessageListener(board));

0 commit comments

Comments
 (0)