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 d4a27c30..7e3ada7a 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 @@ -223,50 +223,55 @@ export class Effects { case SSVC_TYPE_SYNC_ROOM_USER: { const roomUserData = res as RoomUserData; - if ( - roomList.length > 0 && - roomList.filter(r => r.roomSeq === roomUserData.roomSeq) - .length > 0 - ) { - if (!roomUserInfoMap[roomUserData.roomSeq]) { - roomUserInfoMap[roomUserData.roomSeq] = { - userInfoList: [], - userInfoShortList: [] - }; - } - roomUserInfoMap[ - roomUserData.roomSeq - ].userInfoShortList.push(...roomUserData.userInfos); + if (!roomUserInfoMap[roomUserData.roomSeq]) { + roomUserInfoMap[roomUserData.roomSeq] = { + userInfoList: [], + userInfoShortList: [] + }; } + roomUserInfoMap[ + roomUserData.roomSeq + ].userInfoShortList.push(...roomUserData.userInfos); } break; case SSVC_TYPE_SYNC_ROOM_USER2: { const roomUserDetailData = res as RoomUserDetailData; - if ( - roomList.length > 0 && - roomList.filter( - r => r.roomSeq === roomUserDetailData.roomSeq - ).length > 0 - ) { - if (!roomUserInfoMap[roomUserDetailData.roomSeq]) { - roomUserInfoMap[roomUserDetailData.roomSeq] = { - userInfoList: [], - userInfoShortList: [] - }; - } - roomUserInfoMap[ - roomUserDetailData.roomSeq - ].userInfoList.push(...roomUserDetailData.userInfos); + if (!roomUserInfoMap[roomUserDetailData.roomSeq]) { + roomUserInfoMap[roomUserDetailData.roomSeq] = { + userInfoList: [], + userInfoShortList: [] + }; } + roomUserInfoMap[ + roomUserDetailData.roomSeq + ].userInfoList.push(...roomUserDetailData.userInfos); } break; case SSVC_TYPE_SYNC_ROOM_RES: { + const tmpRoomUserInfoMap: { + [param: string]: { + userInfoShortList: UserInfoShort[]; + userInfoList: RoomUserInfo[]; + }; + } = {}; + + roomList.forEach(roomInfo => { + for (const key in roomUserInfoMap) { + if ( + key === roomInfo.roomSeq && + roomUserInfoMap.hasOwnProperty(key) + ) { + tmpRoomUserInfoMap[key] = roomUserInfoMap[key]; + } + } + }); + this.store.dispatch( roomSuccess({ roomList, - roomUserInfoMap, + roomUserInfoMap: tmpRoomUserInfoMap, syncDate: (res as RoomResponse).syncDate }) );