11import { Component , HostListener , OnDestroy , ChangeDetectorRef , ViewChild } from '@angular/core' ;
22import { ActivatedRoute , Event , NavigationEnd , Router } from '@angular/router' ;
33import { animate , style , transition , trigger } from '@angular/animations' ;
4+ import { NotifierService } from '@ert78gb/angular-notifier' ;
45import { faPuzzlePiece , faArrowUp } from '@fortawesome/free-solid-svg-icons' ;
6+ import { Actions , ofType } from '@ngrx/effects' ;
57import { SplitGutterInteractionEvent } from 'angular-split' ;
68import { Observable , Subscription } from 'rxjs' ;
79import { Action , Store } from '@ngrx/store' ;
10+ import { ERR_UPDATER_INVALID_SIGNATURE } from 'uhk-common' ;
811
12+ import { ActionTypes as AppUpdateActionTypes } from './store/actions/app-update.action' ;
913import { DoNotUpdateAppAction , UpdateAppAction } from './store/actions/app-update.action' ;
1014import { EnableUsbStackTestAction , UpdateFirmwareAction } from './store/actions/device' ;
1115import {
@@ -102,6 +106,7 @@ import { SecondSideMenuContainerComponent } from './components/side-menu';
102106} )
103107export class MainAppComponent implements OnDestroy {
104108 @ViewChild ( SecondSideMenuContainerComponent ) secondarySideMenuContainer : SecondSideMenuContainerComponent ;
109+ @ViewChild ( 'manuallyUpdateNotification' , { static : true } ) manuallyUpdateNotificationTmpl ;
105110
106111 donglePairingState : DonglePairingState ;
107112 newPairedDevicesState : BleAddingState ;
@@ -120,6 +125,7 @@ export class MainAppComponent implements OnDestroy {
120125 bottom : 0
121126 } ;
122127 statusBuffer : string ;
128+ private actionsSubscription : Subscription ;
123129 private donglePairingStateSubscription : Subscription ;
124130 private newPairedDevicesStateSubscription : Subscription ;
125131 private errorPanelHeightSubscription : Subscription ;
@@ -136,7 +142,22 @@ export class MainAppComponent implements OnDestroy {
136142 constructor ( private store : Store < AppState > ,
137143 private route : ActivatedRoute ,
138144 private router : Router ,
139- private cdRef : ChangeDetectorRef ) {
145+ private cdRef : ChangeDetectorRef ,
146+ private actions$ : Actions ,
147+ private notificationService : NotifierService ,
148+ ) {
149+ this . actionsSubscription = actions$ . pipe (
150+ ofType ( AppUpdateActionTypes . InvalidCodesignSignature )
151+ )
152+ . subscribe ( ( ) => {
153+ notificationService . show ( {
154+ message : '' ,
155+ type : 'info' ,
156+ template : this . manuallyUpdateNotificationTmpl ,
157+ id : ERR_UPDATER_INVALID_SIGNATURE ,
158+ } )
159+ } )
160+
140161 this . donglePairingStateSubscription = store . select ( getDonglePairingState )
141162 . subscribe ( data => {
142163 this . donglePairingState = data ;
@@ -211,6 +232,7 @@ export class MainAppComponent implements OnDestroy {
211232 }
212233
213234 ngOnDestroy ( ) : void {
235+ this . actionsSubscription . unsubscribe ( ) ;
214236 this . donglePairingStateSubscription . unsubscribe ( ) ;
215237 this . newPairedDevicesStateSubscription . unsubscribe ( ) ;
216238 this . errorPanelHeightSubscription . unsubscribe ( ) ;
@@ -263,6 +285,10 @@ export class MainAppComponent implements OnDestroy {
263285 this . store . dispatch ( new CloseErrorPanelAction ( ) ) ;
264286 }
265287
288+ dismissUpdateErrorNotification ( ) : void {
289+ this . notificationService . hide ( ERR_UPDATER_INVALID_SIGNATURE ) ;
290+ }
291+
266292 showErrorPanel ( ) : void {
267293 this . store . dispatch ( new ShowErrorPanelAction ( ) ) ;
268294 }
0 commit comments