1
0
mirror of https://github.com/NicolasConstant/sengi synced 2025-02-03 03:47:35 +01:00

wired workerservice with update notification

This commit is contained in:
Nicolas Constant 2020-02-26 00:18:06 -05:00
parent b72049fd28
commit 55edfbd24a
No known key found for this signature in database
GPG Key ID: 1E9F677FB01A5688
2 changed files with 15 additions and 11 deletions

View File

@ -12,7 +12,7 @@
<div class="auto-update" [class.auto-update__activated]="updateAvailable">
<div class="auto-update__display">
<div class="auto-update__display--text">A new version is available!</div> <a href class="auto-update__display--reload">reload</a> <a href class="auto-update__display--close" (click)="closeAutoUpdate()"><fa-icon [icon]="faTimes"></fa-icon></a>
<div class="auto-update__display--text">A new version is available!</div> <a href class="auto-update__display--reload" (click)="loadNewVersion()">reload</a> <a href class="auto-update__display--close" (click)="closeAutoUpdate()"><fa-icon [icon]="faTimes"></fa-icon></a>
</div>
</div>

View File

@ -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<StreamElement[]>;
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(() => {