수정(기능추가) :: 상대방이 대화 회수 시 대화 > 리스트의 방정보 갱신(finalEventMessage)
This commit is contained in:
parent
c90656aabb
commit
c437e846fb
@ -26,6 +26,7 @@ import {
|
||||
} from '@ucap-webmessenger/protocol-event';
|
||||
|
||||
import * as ChatStore from '@app/store/messenger/chat';
|
||||
import * as SyncStore from '@app/store/messenger/sync';
|
||||
|
||||
import {
|
||||
info,
|
||||
@ -44,6 +45,8 @@ import {
|
||||
} from './actions';
|
||||
import { SessionStorageService } from '@ucap-webmessenger/web-storage';
|
||||
import { RoomInfo } from '@ucap-webmessenger/protocol-room';
|
||||
import { refreshRoom } from '../sync';
|
||||
import { LoginInfo, KEY_LOGIN_INFO } from '@app/types';
|
||||
|
||||
@Injectable()
|
||||
export class Effects {
|
||||
@ -201,13 +204,24 @@ export class Effects {
|
||||
)
|
||||
),
|
||||
tap(([action, roomInfo]) => {
|
||||
// 현재 방이 오픈되어 있으면 방내용 갱신
|
||||
if (!!roomInfo && roomInfo.roomSeq === action.noti.roomSeq) {
|
||||
this.logger.debug('cancelNotification$', action, roomInfo);
|
||||
this.store.dispatch(
|
||||
recallInfoList({ eventSeq: action.noti.eventSeq })
|
||||
);
|
||||
// this.store.dispatch(ChatStore.newEventMessage(action));
|
||||
}
|
||||
// 대화 > 리스트의 항목 갱신
|
||||
const loginInfo = this.sessionStorageService.get<LoginInfo>(
|
||||
KEY_LOGIN_INFO
|
||||
);
|
||||
this.store.dispatch(
|
||||
SyncStore.refreshRoom({
|
||||
roomSeq: action.noti.roomSeq,
|
||||
isDetail: true,
|
||||
localeCode: loginInfo.localeCode
|
||||
})
|
||||
);
|
||||
})
|
||||
);
|
||||
},
|
||||
|
@ -10,7 +10,8 @@ import {
|
||||
import {
|
||||
RoomInfo,
|
||||
UserInfoShort,
|
||||
UserInfo as RoomUserInfo
|
||||
UserInfo as RoomUserInfo,
|
||||
InfoRequest
|
||||
} from '@ucap-webmessenger/protocol-room';
|
||||
import { Info } from '@ucap-webmessenger/protocol-event';
|
||||
|
||||
@ -75,3 +76,20 @@ export const updateRoomForNewEventMessage = createAction(
|
||||
info: Info;
|
||||
}>()
|
||||
);
|
||||
|
||||
export const refreshRoom = createAction(
|
||||
'[Messenger::Sync] refresh room in sync',
|
||||
props<InfoRequest>()
|
||||
);
|
||||
export const refreshRoomSuccess = createAction(
|
||||
'[Messenger::Sync] refresh room in sync Success',
|
||||
props<{
|
||||
roomInfo: RoomInfo;
|
||||
userInfoShortList: UserInfoShort[];
|
||||
userInfoList: RoomUserInfo[];
|
||||
}>()
|
||||
);
|
||||
export const refreshRoomFailure = createAction(
|
||||
'[Messenger::Sync] refresh room in sync Failure',
|
||||
props<{ error: any }>()
|
||||
);
|
||||
|
@ -26,7 +26,10 @@ import {
|
||||
room,
|
||||
roomFailure,
|
||||
roomSuccess,
|
||||
updateRoomForNewEventMessage
|
||||
updateRoomForNewEventMessage,
|
||||
refreshRoom,
|
||||
refreshRoomFailure,
|
||||
refreshRoomSuccess
|
||||
} from './actions';
|
||||
import { SessionStorageService } from '@ucap-webmessenger/web-storage';
|
||||
|
||||
@ -54,7 +57,15 @@ import { regViewSuccess } from '@app/store/messenger/option';
|
||||
import {
|
||||
RoomInfo,
|
||||
UserInfoShort,
|
||||
UserInfo as RoomUserInfo
|
||||
UserInfo as RoomUserInfo,
|
||||
RoomProtocolService,
|
||||
SSVC_TYPE_ROOM_INFO_ROOM,
|
||||
SSVC_TYPE_ROOM_INFO_USER,
|
||||
SSVC_TYPE_ROOM_INFO_USER2,
|
||||
InfoData,
|
||||
UserShortData,
|
||||
UserData,
|
||||
SSVC_TYPE_ROOM_INFO_RES
|
||||
} from '@ucap-webmessenger/protocol-room';
|
||||
import { LoginInfo, KEY_LOGIN_INFO } from '@app/types';
|
||||
|
||||
@ -241,10 +252,56 @@ export class Effects {
|
||||
{ dispatch: false }
|
||||
);
|
||||
|
||||
refreshRoom$ = createEffect(
|
||||
() => {
|
||||
let roomInfo: RoomInfo;
|
||||
let userInfoShortList: UserInfoShort[];
|
||||
let userInfoList: RoomUserInfo[];
|
||||
|
||||
return this.actions$.pipe(
|
||||
ofType(refreshRoom),
|
||||
tap(() => {
|
||||
roomInfo = null;
|
||||
userInfoShortList = [];
|
||||
userInfoList = [];
|
||||
}),
|
||||
switchMap(req => {
|
||||
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 })))
|
||||
);
|
||||
})
|
||||
);
|
||||
},
|
||||
{ dispatch: false }
|
||||
);
|
||||
|
||||
constructor(
|
||||
private actions$: Actions,
|
||||
private store: Store<any>,
|
||||
private syncProtocolService: SyncProtocolService,
|
||||
private roomProtocolService: RoomProtocolService,
|
||||
private sessionStorageService: SessionStorageService,
|
||||
private logger: NGXLogger
|
||||
) {}
|
||||
|
@ -11,7 +11,8 @@ import {
|
||||
buddy2Success,
|
||||
group2Success,
|
||||
roomSuccess,
|
||||
updateRoomForNewEventMessage
|
||||
updateRoomForNewEventMessage,
|
||||
refreshRoomSuccess
|
||||
} from './actions';
|
||||
import {
|
||||
RoomUserDetailData,
|
||||
@ -113,6 +114,37 @@ export const reducer = createReducer(
|
||||
};
|
||||
}),
|
||||
|
||||
on(refreshRoomSuccess, (state, action) => {
|
||||
const roomUserList: RoomUserDetailData[] = [];
|
||||
const roomUserShortList: RoomUserData[] = [];
|
||||
|
||||
if (action.userInfoList) {
|
||||
roomUserList.push({
|
||||
roomSeq: action.roomInfo.roomSeq,
|
||||
userInfos: action.userInfoList
|
||||
});
|
||||
}
|
||||
if (action.userInfoShortList) {
|
||||
roomUserShortList.push({
|
||||
roomSeq: action.roomInfo.roomSeq,
|
||||
userInfos: action.userInfoShortList
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
...state,
|
||||
room: adapterRoom.upsertOne(action.roomInfo, {
|
||||
...state.room
|
||||
}),
|
||||
roomUser: adapterRoomUser.upsertMany(roomUserList, {
|
||||
...state.roomUser
|
||||
}),
|
||||
roomUserShort: adapterRoomUserShort.upsertMany(roomUserShortList, {
|
||||
...state.roomUserShort
|
||||
})
|
||||
};
|
||||
}),
|
||||
|
||||
on(AuthenticationStore.logout, (state, action) => {
|
||||
return {
|
||||
...initialState
|
||||
|
Loading…
x
Reference in New Issue
Block a user