99 lines
2.8 KiB
TypeScript
Raw Normal View History

2020-02-21 16:38:01 +09:00
import { VersionInfo2Response } from './../../../../../../ucap-webmessenger-api-public/src/lib/apis/version-info2';
2019-11-21 10:29:19 +09:00
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';
2020-02-21 16:38:01 +09:00
import {
DialogService,
AlertDialogComponent,
AlertDialogData,
AlertDialogResult
} from '@ucap-webmessenger/ui';
2019-11-21 10:29:19 +09:00
2020-02-21 16:38:01 +09:00
import { showDialog, selectedGnbMenuIndex } from './actions';
2019-11-21 10:29:19 +09:00
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';
2020-02-21 16:38:01 +09:00
import { KEY_VER_INFO } from '@app/types';
2019-11-21 10:29:19 +09:00
@Injectable()
export class Effects {
showDialog$ = createEffect(
() =>
this.actions$.pipe(
ofType(showDialog),
tap(async () => {
const loginRes = this.sessionStorageService.get<LoginResponse>(
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: {}
});
}
2019-11-21 10:29:19 +09:00
})
),
{ dispatch: false }
);
2020-02-21 16:38:01 +09:00
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 }
);
2019-11-21 10:29:19 +09:00
constructor(
private actions$: Actions,
private store: Store<any>,
private dialogService: DialogService,
private logger: NGXLogger,
private sessionStorageService: SessionStorageService
2019-11-21 10:29:19 +09:00
) {}
}