이미 열린 방에 대해서 다시 열고자 할때 갱신하지 않도록 수정. 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' '[Messenger::Chat] clearSelectedRoom'
); );
export const clearEvent = createAction('[Messenger::Room] Clear Event');
export const newEventMessage = createAction( export const newEventMessage = createAction(
'[Messenger::Chat] newEventMessage', '[Messenger::Chat] newEventMessage',
props<{ props<{

View File

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

View File

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