fix serviceworker registration and update check
This commit is contained in:
parent
55edfbd24a
commit
0cd16fd0de
|
@ -129,9 +129,6 @@ export class AppComponent implements OnInit, OnDestroy {
|
|||
|
||||
closeAutoUpdate(): boolean {
|
||||
this.updateAvailable = false;
|
||||
setTimeout(() => {
|
||||
this.updateAvailable = true;
|
||||
}, 2000);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,11 +22,17 @@ export class ServiceWorkerService {
|
|||
});
|
||||
|
||||
// Allow the app to stabilize first, before starting polling for updates with `interval()`.
|
||||
const appIsStable$ = appRef.isStable.pipe(first(isStable => isStable === true));
|
||||
const everySixHours$ = interval(2 * 60 * 60 * 1000);
|
||||
const everySixHoursOnceAppIsStable$ = concat(appIsStable$, everySixHours$);
|
||||
//const appIsStable$ = appRef.isStable.pipe(first(isStable => isStable === true));
|
||||
// const everySixHoursOnceAppIsStable$ = concat(appIsStable$, everySixHours$);
|
||||
// everySixHoursOnceAppIsStable$.subscribe(() => {
|
||||
// console.warn('wat?');
|
||||
// updates.checkForUpdate();
|
||||
// });
|
||||
|
||||
everySixHoursOnceAppIsStable$.subscribe(() => updates.checkForUpdate());
|
||||
const updateCheckTimer$ = interval(2 * 60 * 60 * 1000);
|
||||
updateCheckTimer$.subscribe(() => {
|
||||
updates.checkForUpdate();
|
||||
});
|
||||
}
|
||||
|
||||
loadNewAppVersion() {
|
||||
|
|
|
@ -9,4 +9,9 @@ if (environment.production) {
|
|||
}
|
||||
|
||||
platformBrowserDynamic().bootstrapModule(AppModule)
|
||||
.then(() => {
|
||||
if ('serviceWorker' in navigator && environment.production) {
|
||||
navigator.serviceWorker.register('./ngsw-worker.js');
|
||||
}
|
||||
})
|
||||
.catch(err => console.log(err));
|
||||
|
|
Loading…
Reference in New Issue