이미 열린 방에 대해서 다시 열고자 할때 갱신하지 않도록 수정. ChatStore.selectedRoom effect 수정.

This commit is contained in:
leejinho 2020-02-06 16:51:24 +09:00
parent 97befdc860
commit 81866a23fb
3 changed files with 32 additions and 15 deletions

View File

@ -21,6 +21,8 @@ export const clearSelectedRoom = createAction(
'[Messenger::Chat] clearSelectedRoom'
);
export const clearEvent = createAction('[Messenger::Room] Clear Event');
export const newEventMessage = createAction(
'[Messenger::Chat] newEventMessage',
props<{

View File

@ -144,7 +144,7 @@ export const reducer = createReducer(
};
}),
on(ChatStore.selectedRoom, (state, action) => {
on(ChatStore.clearEvent, (state, action) => {
return {
...initialState
};

View File

@ -76,20 +76,35 @@ import { LoginInfo, KEY_LOGIN_INFO } from '@app/types';
@Injectable()
export class Effects {
selectedRoomForInfo$ = createEffect(() =>
this.actions$.pipe(
ofType(ChatStore.selectedRoom),
map(action => {
const loginInfo = this.sessionStorageService.get<LoginInfo>(
KEY_LOGIN_INFO
);
return info({
roomSeq: action.roomSeq,
isDetail: true,
localeCode: loginInfo.localeCode
});
})
)
selectedRoomForInfo$ = createEffect(
() => {
return this.actions$.pipe(
ofType(ChatStore.selectedRoom),
withLatestFrom(
this.store.pipe(
select((state: any) => state.messenger.room.roomInfo as RoomInfo)
)
),
map(([action, roomInfo]) => {
if (!!roomInfo && roomInfo.roomSeq === action.roomSeq) {
} else {
this.store.dispatch(ChatStore.clearEvent());
const loginInfo = this.sessionStorageService.get<LoginInfo>(
KEY_LOGIN_INFO
);
this.store.dispatch(
info({
roomSeq: action.roomSeq,
isDetail: true,
localeCode: loginInfo.localeCode
})
);
}
})
);
},
{ dispatch: false }
);
info$ = createEffect(