Small code refactoring

parent 576b8757
Pipeline #23888 passed with stages
in 12 minutes and 17 seconds
......@@ -141,39 +141,41 @@ export class RootComponent implements OnInit, AfterViewInit {
}
private initializeUpdateToastr(): void {
if (this.swUpdate.isEnabled) {
let swUpdateToast: ActiveToast<any>;
if (!this.swUpdate.isEnabled) {
return;
}
this.swUpdate.available.subscribe((event) => {
console.log('service worker update available');
console.log('current version is', event.current);
console.log('available version is', event.available);
console.log('event type is', event.type);
let swUpdateToast: ActiveToast<any>;
if (swUpdateToast) {
this.toastService.remove(swUpdateToast.toastId);
}
this.swUpdate.available.subscribe((event) => {
console.log('service worker update available');
console.log('current version is', event.current);
console.log('available version is', event.available);
console.log('event type is', event.type);
const message = this.translateService.instant('component.toasts.swupdate.message');
const title = this.translateService.instant('component.toasts.swupdate.title');
swUpdateToast = this.toastService.info(message, title, {
disableTimeOut: true,
toastClass: 'toast show',
});
swUpdateToast.onTap.subscribe(() => {
this.swUpdate.activateUpdate().then(() => document.location.reload());
});
if (swUpdateToast) {
this.toastService.remove(swUpdateToast.toastId);
}
const message = this.translateService.instant('component.toasts.swupdate.message');
const title = this.translateService.instant('component.toasts.swupdate.title');
swUpdateToast = this.toastService.info(message, title, {
disableTimeOut: true,
toastClass: 'toast show',
});
this.swUpdate.activated.subscribe(event => {
console.log('previous version was', event.previous);
console.log('current version is', event.current);
console.log('event type is', event.type);
});
this.swUpdate.checkForUpdate().then(() => {
}).catch((err) => {
console.error('error when checking for update', err);
swUpdateToast.onTap.subscribe(() => {
this.swUpdate.activateUpdate().then(() => document.location.reload());
});
}
});
this.swUpdate.activated.subscribe(event => {
console.log('previous version was', event.previous);
console.log('current version is', event.current);
console.log('event type is', event.type);
});
this.swUpdate.checkForUpdate().then(() => {
}).catch((err) => {
console.error('error when checking for update', err);
});
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment