Skip to content

Commit

Permalink
Do not reload on the first time
Browse files Browse the repository at this point in the history
  • Loading branch information
roginvs committed Nov 3, 2024
1 parent c25f833 commit e7e2975
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion os/web/index.sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const CACHE_FILES = [
"/",
];

const VERSION = 100;
const VERSION = 103;

const ENGINE_CACHE_NAME = "engine";

Expand Down
6 changes: 5 additions & 1 deletion os/web/service_worker_manager.mjs
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
export function registerServiceWorker() {
if ("serviceWorker" in navigator) {
if (window.location.hostname !== "localhost") {
const originalServiceWorker = navigator.serviceWorker.controller;

navigator.serviceWorker.register("index.sw.js");

navigator.serviceWorker.addEventListener("controllerchange", () => {
if (preventReloadCounter > 0) {
isReloadPending = true;
} else {
window.location.reload();
if (originalServiceWorker) {
window.location.reload();
}
}
});
}
Expand Down

0 comments on commit e7e2975

Please sign in to comment.