import { VersionInfo2Response } from './../../../../../../ucap-webmessenger-api-public/src/lib/apis/version-info2'; import { Injectable } from '@angular/core'; import { tap } from 'rxjs/operators'; import { Actions, createEffect, ofType } from '@ngrx/effects'; import { Store } from '@ngrx/store'; import { NGXLogger } from 'ngx-logger'; import { DialogService, AlertDialogComponent, AlertDialogData, AlertDialogResult } from '@ucap-webmessenger/ui'; import { showDialog, selectedGnbMenuIndex } from './actions'; import { MessengerSettingsDialogComponent, MessengerSettingsDialogData, MessengerSettingsDialogResult } from '@app/layouts/messenger/dialogs/settings/messenger-settings.dialog.component'; import { SessionStorageService } from '@ucap-webmessenger/web-storage'; import { LoginResponse } from '@ucap-webmessenger/protocol-authentication'; import { KEY_LOGIN_RES_INFO } from '@app/types/login-res-info.type'; import { KEY_VER_INFO } from '@app/types'; @Injectable() export class Effects { showDialog$ = createEffect( () => this.actions$.pipe( ofType(showDialog), tap(async () => { const loginRes = this.sessionStorageService.get( KEY_LOGIN_RES_INFO ); if (!!loginRes && loginRes.userSeq) { const result = await this.dialogService.open< MessengerSettingsDialogComponent, MessengerSettingsDialogData, MessengerSettingsDialogResult >(MessengerSettingsDialogComponent, { width: '800px', maxWidth: '800px', height: '800px', minHeight: '800px', disableClose: false, data: {} }); } }) ), { dispatch: false } ); selectedGnbMenuIndex$ = createEffect( () => this.actions$.pipe( ofType(selectedGnbMenuIndex), tap(async () => { /** Expired Warnning for license */ const sessionVerinfo = this.sessionStorageService.get< VersionInfo2Response >(KEY_VER_INFO); if ( !!sessionVerinfo && !!sessionVerinfo.isExpired && sessionVerinfo.isExpired.length > 0 ) { this.dialogService.open< AlertDialogComponent, AlertDialogData, AlertDialogResult >(AlertDialogComponent, { disableClose: true, data: { title: 'Warnning!!', html: sessionVerinfo.isExpired } }); } }) ), { dispatch: false } ); constructor( private actions$: Actions, private store: Store, private dialogService: DialogService, private logger: NGXLogger, private sessionStorageService: SessionStorageService ) {} }