diff --git a/projects/ucap-webmessenger-app/src/app/store/messenger/event/actions.ts b/projects/ucap-webmessenger-app/src/app/store/messenger/event/actions.ts index 19830be0..cc3a7043 100644 --- a/projects/ucap-webmessenger-app/src/app/store/messenger/event/actions.ts +++ b/projects/ucap-webmessenger-app/src/app/store/messenger/event/actions.ts @@ -131,6 +131,15 @@ export const forwardAfterRoomOpen = createAction( trgtRoomSeq?: string; }>() ); +export const roomOpenAfterForward = createAction( + '[Messenger::Event] roomOpenAfterForward', + props<{ + senderSeq: number; + req: SendRequest; + trgtUserSeqs?: number[]; + trgtRoomSeq?: string; + }>() +); export const sendMass = createAction( '[Messenger::Event] Send Mass', diff --git a/projects/ucap-webmessenger-app/src/app/store/messenger/event/effects.ts b/projects/ucap-webmessenger-app/src/app/store/messenger/event/effects.ts index 5d91b087..a666e67c 100644 --- a/projects/ucap-webmessenger-app/src/app/store/messenger/event/effects.ts +++ b/projects/ucap-webmessenger-app/src/app/store/messenger/event/effects.ts @@ -74,7 +74,8 @@ import { infoIntervalClear, fileInfo, fileInfoSuccess, - fileInfoFailure + fileInfoFailure, + roomOpenAfterForward } from './actions'; import { SessionStorageService } from '@ucap-webmessenger/web-storage'; import { @@ -394,41 +395,10 @@ export class Effects { () => { return this.actions$.pipe( ofType(forward), - withLatestFrom( - this.store.pipe( - select( - (state: any) => - state.messenger.sync.roomUserShort.entities as Dictionary< - RoomUserData - > - ) - ) - ), - tap(([action, roomUserList]) => { + tap(action => { if (!!action.trgtRoomSeq) { - this.store.dispatch( - forwardAfterRoomOpen({ - senderSeq: action.senderSeq, - req: action.req, - trgtUserSeqs: roomUserList[action.trgtRoomSeq].userInfos.map( - user => user.seq - ) - }) - ); - - // this.store.dispatch( - // ChatStore.selectedRoom({ roomSeq: action.trgtRoomSeq }) - // ); - // this.store.dispatch( - // send({ - // senderSeq: action.senderSeq, - // req: { - // roomSeq: action.trgtRoomSeq, - // eventType: action.req.eventType, - // sentMessage: action.req.sentMessage - // } - // }) - // ); + // 대화전달 후 방오픈. + this.store.dispatch(roomOpenAfterForward(action)); } else if (!!action.trgtUserSeqs && action.trgtUserSeqs.length > 0) { // 방오픈 후 대화전달. this.store.dispatch(forwardAfterRoomOpen(action)); @@ -471,6 +441,34 @@ export class Effects { ) ); + roomOpenAfterForward$ = createEffect(() => + this.actions$.pipe( + ofType(roomOpenAfterForward), + concatMap(action => { + return this.eventProtocolService + .send({ + roomSeq: action.trgtRoomSeq, + eventType: action.req.eventType, + sentMessage: action.req.sentMessage + }) + .pipe( + map((res: SendResponse) => { + this.store.dispatch( + newInfo({ + roomSeq: res.roomSeq, + info: res.info, + SVC_TYPE: res.SVC_TYPE, + SSVC_TYPE: res.SSVC_TYPE + }) + ); + return ChatStore.selectedRoom({ roomSeq: action.trgtRoomSeq }); + }), + catchError(error => of(sendFailure({ error }))) + ); + }) + ) + ); + sendMass$ = createEffect( () => { return this.actions$.pipe(