From 14ab59459f796efbf26c123a58e48ad3835d3d61 Mon Sep 17 00:00:00 2001 From: leejh Date: Thu, 24 Oct 2019 16:53:21 +0900 Subject: [PATCH] =?UTF-8?q?=EA=B8=B0=EB=8A=A5=EC=B6=94=EA=B0=80=20::=201.?= =?UTF-8?q?=20=EB=B0=A9=EB=8B=AB=EA=B8=B0=20=EA=B8=B0=EB=8A=A5=EC=B6=94?= =?UTF-8?q?=EA=B0=80=202.=20=EB=B0=A9=EB=82=98=EA=B0=80=EA=B8=B0=20?= =?UTF-8?q?=EC=8B=9C=20=ED=98=84=EC=9E=AC=20=EC=97=B4=EB=A0=A4=20=EC=9E=88?= =?UTF-8?q?=EB=8A=94=20=EB=B0=A9=20=EB=8B=AB=EC=95=84=EC=A3=BC=EB=8A=94=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../messenger/components/messages.component.html | 4 ++-- .../messenger/components/messages.component.ts | 12 ++++++++++++ .../src/app/store/messenger/chat/actions.ts | 4 ++++ .../src/app/store/messenger/chat/reducers.ts | 10 +++++++++- .../src/app/store/messenger/room/effects.ts | 10 +++++++++- 5 files changed, 36 insertions(+), 4 deletions(-) diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.html b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.html index 4b6e3ed3..1d53b8d9 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.html +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.html @@ -42,8 +42,8 @@ - diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.ts index bfbb5037..40a0d7e0 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.ts @@ -389,4 +389,16 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewChecked { break; } } + + onClickContextMenu(menuType: string) { + switch (menuType) { + case 'CLOSE_ROOM': + { + this.store.dispatch(ChatStore.clearSelectedRoom()); + } + break; + default: + break; + } + } } diff --git a/projects/ucap-webmessenger-app/src/app/store/messenger/chat/actions.ts b/projects/ucap-webmessenger-app/src/app/store/messenger/chat/actions.ts index d55509ee..2da55490 100644 --- a/projects/ucap-webmessenger-app/src/app/store/messenger/chat/actions.ts +++ b/projects/ucap-webmessenger-app/src/app/store/messenger/chat/actions.ts @@ -10,6 +10,10 @@ export const selectedRoom = createAction( props<{ roomSeq: string }>() ); +export const clearSelectedRoom = createAction( + '[Messenger::Chat] clearSelectedRoom' +); + export const newEventMessage = createAction( '[Messenger::Chat] newEventMessage', props<{ diff --git a/projects/ucap-webmessenger-app/src/app/store/messenger/chat/reducers.ts b/projects/ucap-webmessenger-app/src/app/store/messenger/chat/reducers.ts index cd779437..0fcb219b 100644 --- a/projects/ucap-webmessenger-app/src/app/store/messenger/chat/reducers.ts +++ b/projects/ucap-webmessenger-app/src/app/store/messenger/chat/reducers.ts @@ -5,7 +5,8 @@ import { selectedMassDetail, massTalkDownloadFailure, massTalkDownload, - massTalkDownloadSuccess + massTalkDownloadSuccess, + clearSelectedRoom } from './actions'; export const reducer = createReducer( @@ -17,6 +18,13 @@ export const reducer = createReducer( }; }), + on(clearSelectedRoom, (state, action) => { + return { + ...state, + selectedRoom: null + }; + }), + on(selectedMassDetail, (state, action) => { return { ...state, diff --git a/projects/ucap-webmessenger-app/src/app/store/messenger/room/effects.ts b/projects/ucap-webmessenger-app/src/app/store/messenger/room/effects.ts index b0331506..63dd6794 100644 --- a/projects/ucap-webmessenger-app/src/app/store/messenger/room/effects.ts +++ b/projects/ucap-webmessenger-app/src/app/store/messenger/room/effects.ts @@ -181,9 +181,17 @@ export class Effects { exit$ = createEffect(() => this.actions$.pipe( ofType(exit), - exhaustMap(req => { + withLatestFrom( + this.store.pipe( + select((state: any) => state.messenger.room.roomInfo as RoomInfo) + ) + ), + exhaustMap(([req, roomInfo]) => { return this.roomProtocolService.exit(req).pipe( map((res: ExitResponse) => { + if (!!roomInfo && roomInfo.roomSeq === res.roomSeq) { + this.store.dispatch(ChatStore.clearSelectedRoom()); + } return exitSuccess({ res }); }), catchError(error => of(exitFailure({ error })))