로그아웃, 설정 버튼에 대한 유효성 체크.
1. 로그아웃시 보여지지 않게 수정. 2. 로그인 상태가 아닐 경우에 skip 하도록 수정. 3. 로그아웃시 confirm 하도록 수정.
This commit is contained in:
parent
bde11c8711
commit
fd5b4b12f3
|
@ -166,6 +166,7 @@ function createTray() {
|
|||
// accelerator: 'Q',
|
||||
// selector: 'terminate:',
|
||||
click: () => {
|
||||
appWindow.show();
|
||||
appWindow.browserWindow.webContents.send(MessengerChannel.Logout);
|
||||
}
|
||||
},
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
</div>
|
||||
<div class="app-layout-native-title-bar-title">UCAP M Messenger</div>
|
||||
<div class="app-layout-native-title-bar-spacer"></div>
|
||||
<div class="app-layout-native-title-bar-link">
|
||||
<div *ngIf="!!loginRes" class="app-layout-native-title-bar-link">
|
||||
<button
|
||||
mat-icon-button
|
||||
class="button app-layout-native-title-bar-setting"
|
||||
|
|
|
@ -4,12 +4,16 @@ import {
|
|||
NativeService,
|
||||
WindowState
|
||||
} from '@ucap-webmessenger/native';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { Observable, Subscription } from 'rxjs';
|
||||
import { Store, select } from '@ngrx/store';
|
||||
|
||||
import * as AppStore from '@app/store';
|
||||
import * as AuthenticationStore from '@app/store/account/authentication';
|
||||
import * as SettingsStore from '@app/store/messenger/settings';
|
||||
|
||||
import { LoginResponse } from '@ucap-webmessenger/protocol-authentication';
|
||||
import { tap } from 'rxjs/operators';
|
||||
|
||||
@Component({
|
||||
selector: 'app-layout-native-top-bar',
|
||||
templateUrl: './top-bar.component.html',
|
||||
|
@ -19,6 +23,8 @@ export class TopBarComponent implements OnInit, OnDestroy {
|
|||
windowStateChanged$: Observable<WindowState>;
|
||||
|
||||
WindowState = WindowState;
|
||||
loginRes: LoginResponse;
|
||||
loginResSubscription: Subscription;
|
||||
|
||||
constructor(
|
||||
private store: Store<any>,
|
||||
|
@ -27,6 +33,15 @@ export class TopBarComponent implements OnInit, OnDestroy {
|
|||
|
||||
ngOnInit() {
|
||||
this.windowStateChanged$ = this.nativeService.windowStateChanged();
|
||||
|
||||
this.loginResSubscription = this.store
|
||||
.pipe(
|
||||
select(AppStore.AccountSelector.AuthenticationSelector.loginRes),
|
||||
tap(loginRes => {
|
||||
this.loginRes = loginRes;
|
||||
})
|
||||
)
|
||||
.subscribe();
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {}
|
||||
|
@ -48,6 +63,6 @@ export class TopBarComponent implements OnInit, OnDestroy {
|
|||
}
|
||||
|
||||
onClickLogout(): void {
|
||||
this.store.dispatch(AuthenticationStore.logout());
|
||||
this.store.dispatch(AuthenticationStore.logoutConfirmation());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,8 @@ import {
|
|||
} from '@ucap-webmessenger/web-storage';
|
||||
import { LocaleCode } from '@ucap-webmessenger/core';
|
||||
import { LoginInfo, KEY_LOGIN_INFO } from '../types';
|
||||
import { KEY_VER_INFO } from '@app/types/ver-info.type';
|
||||
import { KEY_LOGIN_RES_INFO } from '@app/types/login-res-info.type';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
|
@ -44,6 +46,8 @@ export class AppAuthenticationService {
|
|||
}
|
||||
|
||||
logout() {
|
||||
this.sessionStorageService.remove(KEY_LOGIN_RES_INFO);
|
||||
this.sessionStorageService.remove(KEY_VER_INFO);
|
||||
this.sessionStorageService.remove(KEY_LOGIN_INFO);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ export class AppNativeService {
|
|||
|
||||
subscribe(): void {
|
||||
this.nativeService.logout().subscribe(() => {
|
||||
this.store.dispatch(AuthenticationStore.logout());
|
||||
this.store.dispatch(AuthenticationStore.logoutConfirmation());
|
||||
});
|
||||
this.nativeService.changeStatus().subscribe(statusCode => {});
|
||||
this.nativeService.showSetting().subscribe(() => {
|
||||
|
|
|
@ -53,7 +53,11 @@ import {
|
|||
ServiceProtocolService,
|
||||
UserPasswordSetResponse
|
||||
} from '@ucap-webmessenger/protocol-service';
|
||||
import { AuthenticationProtocolService } from '@ucap-webmessenger/protocol-authentication';
|
||||
import {
|
||||
AuthenticationProtocolService,
|
||||
LoginResponse
|
||||
} from '@ucap-webmessenger/protocol-authentication';
|
||||
import { KEY_LOGIN_RES_INFO } from '@app/types/login-res-info.type';
|
||||
|
||||
@Injectable()
|
||||
export class Effects {
|
||||
|
@ -157,19 +161,26 @@ export class Effects {
|
|||
this.actions$.pipe(
|
||||
ofType(logoutConfirmation),
|
||||
exhaustMap(async () => {
|
||||
const loginRes = this.sessionStorageService.get<LoginResponse>(
|
||||
KEY_LOGIN_RES_INFO
|
||||
);
|
||||
|
||||
if (!!loginRes && loginRes.userSeq) {
|
||||
const result = await this.dialogService.open<
|
||||
ConfirmDialogComponent,
|
||||
ConfirmDialogData,
|
||||
ConfirmDialogResult
|
||||
>(ConfirmDialogComponent, {
|
||||
width: '220px',
|
||||
data: {
|
||||
title: 'Logout',
|
||||
message: 'Logout ?'
|
||||
message: '로그아웃 하시겠습니까?'
|
||||
}
|
||||
});
|
||||
|
||||
return result.choice;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}),
|
||||
map(result => (result ? logout() : logoutConfirmationDismiss()))
|
||||
)
|
||||
|
|
|
@ -15,6 +15,9 @@ import {
|
|||
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';
|
||||
|
||||
@Injectable()
|
||||
export class Effects {
|
||||
|
@ -23,6 +26,11 @@ export class Effects {
|
|||
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,
|
||||
|
@ -35,6 +43,7 @@ export class Effects {
|
|||
disableClose: false,
|
||||
data: {}
|
||||
});
|
||||
}
|
||||
})
|
||||
),
|
||||
{ dispatch: false }
|
||||
|
@ -44,6 +53,7 @@ export class Effects {
|
|||
private actions$: Actions,
|
||||
private store: Store<any>,
|
||||
private dialogService: DialogService,
|
||||
private logger: NGXLogger
|
||||
private logger: NGXLogger,
|
||||
private sessionStorageService: SessionStorageService
|
||||
) {}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user