diff --git a/src/webpage/utils/utils.ts b/src/webpage/utils/utils.ts index 798fb31..17c565f 100644 --- a/src/webpage/utils/utils.ts +++ b/src/webpage/utils/utils.ts @@ -856,7 +856,13 @@ export class SW { port.port1.close(); }); this.postMessage({code: "ping"}); + const func = (update: boolean) => { + this.needsUpdate ||= update; + this.stopWatchForUpdates(func); + }; + this.watchForUpdates(func); } + static needsUpdate = false; static postMessage(message: messageTo) { this.port?.postMessage(message); } @@ -893,6 +899,7 @@ export class SW { } } static async checkUpdates(): Promise { + if (this.needsUpdate) return true; return new Promise((res) => { const func = (update: boolean) => { this.stopWatchForUpdates(func);