From 45692022305a40cb5b3fe634c12f7ea20bfceb47 Mon Sep 17 00:00:00 2001 From: leejinho Date: Tue, 4 Feb 2020 16:34:27 +0900 Subject: [PATCH] =?UTF-8?q?bugfix=20::=201.=20=EA=B0=95=EC=A0=9C=ED=87=B4?= =?UTF-8?q?=EC=9E=A5=EC=8B=9C=20state=20=EC=97=90=EC=84=9C=20remove=20?= =?UTF-8?q?=ED=95=98=EC=A7=80=20=EC=95=8A=EA=B3=A0=20isJoinRoom=20?= =?UTF-8?q?=ED=94=8C=EB=9E=98=EA=B7=B8=EB=A7=8C=20=EB=B3=80=EA=B2=BD?= =?UTF-8?q?=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95.=202.=20?= =?UTF-8?q?=EB=8C=80=ED=99=94=EC=83=81=EB=8C=80=20=EC=B4=88=EB=8C=80?= =?UTF-8?q?=EC=8B=9C=20=EB=B0=A9=EC=A0=95=EB=B3=B4=EB=A5=BC=20=EA=B0=B1?= =?UTF-8?q?=EC=8B=A0=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95.=20>>?= =?UTF-8?q?=20INVITE=5FNOTI=20=EC=97=90=20=EC=B4=88=EB=8C=80=EC=9E=90=20?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=EA=B0=80=20=EC=9C=A0=EC=9E=85=EB=90=98?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EC=9D=8C.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/messages.component.ts | 6 --- .../src/app/services/notification.service.ts | 53 ++++++++++++------- .../src/app/store/messenger/room/actions.ts | 5 +- .../src/app/store/messenger/room/effects.ts | 31 ++++++++--- .../src/app/store/messenger/room/reducers.ts | 45 +++++++++++++--- .../src/app/store/messenger/sync/actions.ts | 2 +- .../src/app/store/messenger/sync/effects.ts | 8 +++ .../src/app/store/messenger/sync/reducers.ts | 46 ++++++++++------ 8 files changed, 139 insertions(+), 57 deletions(-) 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 a144f052..20fc8326 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 @@ -1286,12 +1286,6 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit { (message as Info).sentMessage ) ) { - this.snackBarService.open( - this.translateService.instant( - 'common.clipboard.results.copied' - ), - '확인' - ); this.snackBarService.open( this.translateService.instant( 'common.clipboard.results.copied' diff --git a/projects/ucap-webmessenger-app/src/app/services/notification.service.ts b/projects/ucap-webmessenger-app/src/app/services/notification.service.ts index 43e81e5a..a13b3352 100644 --- a/projects/ucap-webmessenger-app/src/app/services/notification.service.ts +++ b/projects/ucap-webmessenger-app/src/app/services/notification.service.ts @@ -474,6 +474,20 @@ export class AppNotificationService { ); } break; + case SSVC_TYPE_ROOM_INVITE_NOTI: + { + const noti = notiOrRes as InviteNotification; + this.logger.debug( + 'Notification::roomProtocolService::InviteNotification', + noti + ); + this.store.dispatch( + RoomStore.inviteNotification({ + noti + }) + ); + } + break; case SSVC_TYPE_ROOM_UPD_RES: { const noti = notiOrRes as RoomUpdateNotification; @@ -496,20 +510,6 @@ export class AppNotificationService { ); } break; - case SSVC_TYPE_ROOM_INVITE_NOTI: - { - const noti = notiOrRes as InviteNotification; - this.logger.debug( - 'Notification::roomProtocolService::InviteNotification', - noti - ); - this.store.dispatch( - RoomStore.inviteNotification({ - noti - }) - ); - } - break; case SSVC_TYPE_ROOM_EXIT_RES: case SSVC_TYPE_ROOM_EXIT_NOTI: { @@ -528,7 +528,8 @@ export class AppNotificationService { } else { this.store.dispatch( RoomStore.exitNotificationOthers({ - noti + roomSeq: noti.roomSeq, + trgtUser: [noti.SENDER_SEQ] }) ); @@ -560,15 +561,31 @@ export class AppNotificationService { break; case SSVC_TYPE_ROOM_EXIT_FORCING_NOTI: { - // 내가 강퇴 됨. const noti = notiOrRes as ExitForcingNotification; this.logger.debug( 'Notification::roomProtocolService::ExitForcingNotification NOTI', noti ); + + if (noti.userSeqs.indexOf(loginResInfo.userSeq) >= 0) { + this.store.dispatch( + RoomStore.exitForcingNotification({ + noti + }) + ); + } + this.store.dispatch( - RoomStore.exitForcingNotification({ - noti + RoomStore.exitNotificationOthers({ + roomSeq: noti.roomSeq, + trgtUser: noti.userSeqs + }) + ); + + this.store.dispatch( + SyncStore.clearRoomUsers({ + roomSeq: noti.roomSeq, + userSeqs: noti.userSeqs }) ); } diff --git a/projects/ucap-webmessenger-app/src/app/store/messenger/room/actions.ts b/projects/ucap-webmessenger-app/src/app/store/messenger/room/actions.ts index 02427292..be56cadb 100644 --- a/projects/ucap-webmessenger-app/src/app/store/messenger/room/actions.ts +++ b/projects/ucap-webmessenger-app/src/app/store/messenger/room/actions.ts @@ -56,9 +56,12 @@ export const exitNotification = createAction( '[Messenger::Room] Exit Notification', props<{ noti: ExitNotification }>() ); +/** + * 현재 열려 있는 방의 방참여인원의 isJoinRoom flag 를 false 로 변경. + */ export const exitNotificationOthers = createAction( '[Messenger::Room] Exit Notification By Others', - props<{ noti: ExitNotification }>() + props<{ roomSeq: string; trgtUser: number[] }>() ); export const exitForcing = createAction( 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 966aa15a..3f7e14ae 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 @@ -310,8 +310,25 @@ export class Effects { () => { return this.actions$.pipe( ofType(inviteNotification), - map(action => action.noti), - tap(noti => {}) + withLatestFrom( + this.store.pipe( + select((state: any) => state.messenger.room.roomInfo as RoomInfo) + ) + ), + tap(([action, roomInfo]) => { + if (!!roomInfo && roomInfo.roomSeq === action.noti.roomSeq) { + const loginInfo = this.sessionStorageService.get( + KEY_LOGIN_INFO + ); + this.store.dispatch( + info({ + roomSeq: action.noti.roomSeq, + isDetail: true, + localeCode: loginInfo.localeCode + }) + ); + } + }) ); }, { dispatch: false } @@ -354,13 +371,11 @@ export class Effects { tap(([action, roomInfo]) => { if ( !!roomInfo && - roomInfo.roomSeq === action.noti.roomSeq && - !!action.noti && - !!action.noti.SENDER_SEQ + roomInfo.roomSeq === action.roomSeq && + !!action.trgtUser && + action.trgtUser.length > 0 ) { - this.store.dispatch( - clearRoomUser({ userSeqs: [action.noti.SENDER_SEQ] }) - ); + this.store.dispatch(clearRoomUser({ userSeqs: action.trgtUser })); } }) ); diff --git a/projects/ucap-webmessenger-app/src/app/store/messenger/room/reducers.ts b/projects/ucap-webmessenger-app/src/app/store/messenger/room/reducers.ts index 5969f577..4d3842f0 100644 --- a/projects/ucap-webmessenger-app/src/app/store/messenger/room/reducers.ts +++ b/projects/ucap-webmessenger-app/src/app/store/messenger/room/reducers.ts @@ -10,7 +10,7 @@ import { import * as AuthenticationStore from '@app/store/account/authentication'; import * as ChatStore from '@app/store/messenger/chat'; -import { UserInfo } from '@ucap-webmessenger/protocol-room'; +import { UserInfo, UserInfoShort } from '@ucap-webmessenger/protocol-room'; export const reducer = createReducer( initialState, @@ -28,14 +28,45 @@ export const reducer = createReducer( }), on(clearRoomUser, (state, action) => { + const tmpUserInfoList: UserInfo[] = []; + const tmpUserInfoShortList: UserInfoShort[] = []; + action.userSeqs.forEach(userSeq => { + const userInfo: UserInfo = { + ...state.userInfoList.entities[userSeq] + }; + + if (!!userInfo && !!userInfo.seq) { + tmpUserInfoList.push({ + ...userInfo, + isJoinRoom: false + }); + } + + const userInfoShort: UserInfoShort = { + ...state.userInfoShortList.entities[userSeq] + }; + if (!!userInfoShort && !!userInfoShort.seq) { + tmpUserInfoShortList.push({ + ...userInfoShort, + isJoinRoom: false + }); + } + }); + return { ...state, - userInfoList: adapterUserInfo.removeMany(action.userSeqs, { - ...state.userInfoList - }), - userInfoShortList: adapterUserInfoShort.removeMany(action.userSeqs, { - ...state.userInfoShortList - }) + userInfoList: + tmpUserInfoList.length > 0 + ? adapterUserInfo.upsertMany(tmpUserInfoList, { + ...state.userInfoList + }) + : state.userInfoList, + userInfoShortList: + tmpUserInfoShortList.length > 0 + ? adapterUserInfoShort.upsertMany(tmpUserInfoShortList, { + ...state.userInfoShortList + }) + : state.userInfoShortList }; }), diff --git a/projects/ucap-webmessenger-app/src/app/store/messenger/sync/actions.ts b/projects/ucap-webmessenger-app/src/app/store/messenger/sync/actions.ts index 342f2a60..2a80c28e 100644 --- a/projects/ucap-webmessenger-app/src/app/store/messenger/sync/actions.ts +++ b/projects/ucap-webmessenger-app/src/app/store/messenger/sync/actions.ts @@ -264,7 +264,7 @@ export const delGroupFailure = createAction( props<{ error: any }>() ); -/** 방 인원 클리어 */ +/** Sync 되어 있는 방의 방인원의 isJoinRoom flag 를 false 로 변경. */ export const clearRoomUsers = createAction( '[Messenger::Sync] Clear room users.', props<{ roomSeq: string; userSeqs: number[] }>() diff --git a/projects/ucap-webmessenger-app/src/app/store/messenger/sync/effects.ts b/projects/ucap-webmessenger-app/src/app/store/messenger/sync/effects.ts index a6ea6f4a..b52dc94c 100644 --- a/projects/ucap-webmessenger-app/src/app/store/messenger/sync/effects.ts +++ b/projects/ucap-webmessenger-app/src/app/store/messenger/sync/effects.ts @@ -342,6 +342,10 @@ export class Effects { let roomSeq = null; for (const key in roomUsers) { + if (key === undefined) { + continue; + } + if (roomUsers.hasOwnProperty(key)) { const element = roomUsers[key]; if (userSeqList.length === element.userInfos.length) { @@ -371,6 +375,10 @@ export class Effects { } for (const key in roomUserShorts) { + if (key === undefined) { + continue; + } + if (roomUserShorts.hasOwnProperty(key)) { const element = roomUserShorts[key]; if (userSeqList.length === element.userInfos.length) { diff --git a/projects/ucap-webmessenger-app/src/app/store/messenger/sync/reducers.ts b/projects/ucap-webmessenger-app/src/app/store/messenger/sync/reducers.ts index 2cac0931..ea6d0eed 100644 --- a/projects/ucap-webmessenger-app/src/app/store/messenger/sync/reducers.ts +++ b/projects/ucap-webmessenger-app/src/app/store/messenger/sync/reducers.ts @@ -103,35 +103,45 @@ export const reducer = createReducer( }), on(clearRoomUsers, (state, action) => { - let roomUserList: RoomUserDetailData = { + const roomUserList: RoomUserDetailData = { ...state.roomUser.entities[action.roomSeq] }; + let trgtRoomUserList: RoomUserDetailData; if ( !!roomUserList && !!roomUserList.userInfos && roomUserList.userInfos.length > 0 ) { - const userInfos = roomUserList.userInfos.filter( - userInfo => action.userSeqs.indexOf(userInfo.seq) < 0 - ); - roomUserList = { + const userInfos = roomUserList.userInfos.map(userInfo => { + if (action.userSeqs.indexOf(userInfo.seq) >= 0) { + return { ...userInfo, isJoinRoom: false }; + } else { + return userInfo; + } + }); + trgtRoomUserList = { ...roomUserList, userInfos }; } - let roomUserShortList: RoomUserData = { + const roomUserShortList: RoomUserData = { ...state.roomUserShort.entities[action.roomSeq] }; + let trgtRoomUserShortList: RoomUserData; if ( !!roomUserShortList && !!roomUserShortList.userInfos && roomUserShortList.userInfos.length > 0 ) { - const userInfos = roomUserShortList.userInfos.filter( - userInfo => action.userSeqs.indexOf(userInfo.seq) < 0 - ); - roomUserShortList = { + const userInfos = roomUserShortList.userInfos.map(userInfo => { + if (action.userSeqs.indexOf(userInfo.seq) >= 0) { + return { ...userInfo, isJoinRoom: false }; + } else { + return userInfo; + } + }); + trgtRoomUserShortList = { ...roomUserShortList, userInfos }; @@ -139,12 +149,16 @@ export const reducer = createReducer( return { ...state, - roomUser: adapterRoomUser.upsertOne(roomUserList, { - ...state.roomUser - }), - roomUserShort: adapterRoomUserShort.upsertOne(roomUserShortList, { - ...state.roomUserShort - }) + roomUser: !!trgtRoomUserList + ? adapterRoomUser.upsertOne(trgtRoomUserList, { + ...state.roomUser + }) + : state.roomUser, + roomUserShort: !!trgtRoomUserShortList + ? adapterRoomUserShort.upsertOne(trgtRoomUserShortList, { + ...state.roomUserShort + }) + : state.roomUserShort }; }),