diff --git a/src/app/services/service-worker.service.ts b/src/app/services/service-worker.service.ts index 2b9dc9ca..2c2ab0f9 100644 --- a/src/app/services/service-worker.service.ts +++ b/src/app/services/service-worker.service.ts @@ -10,6 +10,8 @@ export class ServiceWorkerService { newAppVersionIsAvailable = new BehaviorSubject(false); + private isListening = false; + constructor(appRef: ApplicationRef, updates: SwUpdate) { //https://angular.io/guide/service-worker-communications @@ -30,8 +32,14 @@ export class ServiceWorkerService { // }); const updateCheckTimer$ = interval(6 * 60 * 60 * 1000); - updateCheckTimer$.subscribe(() => { - updates.checkForUpdate(); + + appRef.isStable.subscribe(() => { + if (this.isListening) return; + this.isListening = true; + + updateCheckTimer$.subscribe(() => { + updates.checkForUpdate(); + }); }); } diff --git a/src/manifest.json b/src/manifest.json index 39dc07fa..0133f778 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -5,7 +5,7 @@ "background_color": "#fafafa", "display": "standalone", "scope": "/", - "start_url": "/index.html", + "start_url": "/", "icons": [ { "src": "assets/icons/icon-72x72.png",