From 55edfbd24afb047f7ceae06ff3f1b81880983057 Mon Sep 17 00:00:00 2001 From: Nicolas Constant Date: Wed, 26 Feb 2020 00:18:06 -0500 Subject: [PATCH] wired workerservice with update notification --- src/app/app.component.html | 2 +- src/app/app.component.ts | 24 ++++++++++++++---------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/app/app.component.html b/src/app/app.component.html index 11cb1507..9a1e319a 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -12,7 +12,7 @@
-
A new version is available!
reload +
A new version is available!
reload
diff --git a/src/app/app.component.ts b/src/app/app.component.ts index bfc891f7..4a9c3c04 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -10,6 +10,7 @@ import { StreamElement } from './states/streams.state'; import { OpenMediaEvent } from './models/common.model'; import { ToolsService } from './services/tools.service'; import { MediaService } from './services/media.service'; +import { ServiceWorkerService } from './services/service-worker.service'; @Component({ selector: 'app-root', @@ -21,30 +22,28 @@ export class AppComponent implements OnInit, OnDestroy { title = 'Sengi'; floatingColumnActive: boolean; tutorialActive: boolean; - // mediaViewerActive: boolean = false; openedMediaEvent: OpenMediaEvent + updateAvailable: boolean; private columnEditorSub: Subscription; private openMediaSub: Subscription; private streamSub: Subscription; private dragoverSub: Subscription; - - - updateAvailable: boolean; + private updateAvailableSub: Subscription; @Select(state => state.streamsstatemodel.streams) streamElements$: Observable; constructor( + private readonly serviceWorkerService: ServiceWorkerService, private readonly toolsService: ToolsService, private readonly mediaService: MediaService, private readonly navigationService: NavigationService) { } ngOnInit(): void { - setTimeout(() => { - this.updateAvailable = true; - }, 2000); - + this.updateAvailableSub = this.serviceWorkerService.newAppVersionIsAvailable.subscribe((updateAvailable) => { + this.updateAvailable = updateAvailable; + }); this.streamSub = this.streamElements$.subscribe((streams: StreamElement[]) => { if (streams && streams.length === 0) { @@ -75,7 +74,7 @@ export class AppComponent implements OnInit, OnDestroy { .pipe( debounceTime(1500) ) - .subscribe(() => { + .subscribe(() => { this.drag = false; }) } @@ -85,6 +84,7 @@ export class AppComponent implements OnInit, OnDestroy { this.columnEditorSub.unsubscribe(); this.openMediaSub.unsubscribe(); this.dragoverSub.unsubscribe(); + this.updateAvailableSub.unsubscribe(); } closeMedia() { @@ -106,7 +106,6 @@ export class AppComponent implements OnInit, OnDestroy { return false; } dragover(event): boolean { - // console.warn('dragover'); event.stopPropagation(); event.preventDefault(); this.dragoverSubject.next(true); @@ -123,6 +122,11 @@ export class AppComponent implements OnInit, OnDestroy { return false; } + loadNewVersion(): boolean { + this.serviceWorkerService.loadNewAppVersion(); + return false; + } + closeAutoUpdate(): boolean { this.updateAvailable = false; setTimeout(() => {