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 be56cadb..d6e5f084 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 @@ -188,3 +188,8 @@ export const exitFailure = createAction( '[Messenger::Room] Exit Failure', props<{ error: any }>() ); + +export const syncRoomRefreshByInvite = createAction( + '[Messenger::Room] Sync Room Refresh by invite', + props() +); 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 5caa44ff..9d8a4e81 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 @@ -70,7 +70,8 @@ import { exitForcingFailure, exitForcingSuccess, exitNotificationOthers, - clearRoomUser + clearRoomUser, + syncRoomRefreshByInvite } from './actions'; import { SessionStorageService } from '@ucap-webmessenger/web-storage'; import { LoginInfo, KEY_LOGIN_INFO, KEY_VER_INFO } from '@app/types'; @@ -398,10 +399,11 @@ export class Effects { ) ), tap(([action, roomInfo]) => { + const loginInfo = this.sessionStorageService.get( + KEY_LOGIN_INFO + ); + if (!!roomInfo && roomInfo.roomSeq === action.noti.roomSeq) { - const loginInfo = this.sessionStorageService.get( - KEY_LOGIN_INFO - ); this.store.dispatch( info({ roomSeq: action.noti.roomSeq, @@ -410,6 +412,15 @@ export class Effects { }) ); } + + // room list refresh for exist. + this.store.dispatch( + syncRoomRefreshByInvite({ + roomSeq: action.noti.roomSeq, + isDetail: true, + localeCode: loginInfo.localeCode + }) + ); }) ); }, 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 7e3ada7a..edc41612 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 @@ -540,6 +540,62 @@ export class Effects { }, { dispatch: false } ); + syncRoomRefreshByInvite$ = createEffect( + () => { + let roomInfo: RoomInfo; + let userInfoShortList: UserInfoShort[]; + let userInfoList: RoomUserInfo[]; + + return this.actions$.pipe( + ofType(RoomStore.syncRoomRefreshByInvite), + tap(() => { + roomInfo = null; + userInfoShortList = []; + userInfoList = []; + }), + withLatestFrom( + this.store.pipe( + select((state: any) => state.messenger.sync.room.ids as string[]) + ) + ), + switchMap(([req, roomSeqList]) => { + const index = roomSeqList.findIndex( + (roomSeq, i) => roomSeq === req.roomSeq + ); + if (index > -1) { + return this.roomProtocolService.info(req).pipe( + map(res => { + switch (res.SSVC_TYPE) { + case SSVC_TYPE_ROOM_INFO_ROOM: + roomInfo = (res as InfoData).roomInfo; + break; + case SSVC_TYPE_ROOM_INFO_USER: + userInfoShortList.push(...(res as UserShortData).userInfos); + break; + case SSVC_TYPE_ROOM_INFO_USER2: + userInfoList.push(...(res as UserData).userInfos); + break; + case SSVC_TYPE_ROOM_INFO_RES: + this.store.dispatch( + refreshRoomSuccess({ + roomInfo, + userInfoShortList, + userInfoList + }) + ); + break; + } + }), + catchError(error => of(refreshRoomFailure({ error }))) + ); + } else { + return of(); + } + }) + ); + }, + { dispatch: false } + ); // 대화상대 초대 성공 후 처리. inviteSuccess$ = createEffect(() =>