next-ucap-messenger/projects/ucap-webmessenger-app/src/app/store/messenger/room/reducers.ts

35 lines
807 B
TypeScript
Raw Normal View History

2019-10-08 02:19:47 +00:00
import { createReducer, on } from '@ngrx/store';
import { initialState } from './state';
2019-10-11 06:55:27 +00:00
import { infoSuccess, updateSuccess } from './actions';
2019-10-08 02:19:47 +00:00
2019-10-11 04:11:48 +00:00
import * as AuthenticationStore from '@app/store/account/authentication';
2019-10-08 02:19:47 +00:00
export const reducer = createReducer(
initialState,
on(infoSuccess, (state, action) => {
return {
...state,
roomInfo: action.roomInfo,
userInfoList: action.userInfoList,
userInfoShortList: action.userInfoShortList
};
2019-10-11 04:11:48 +00:00
}),
2019-10-11 06:55:27 +00:00
on(updateSuccess, (state, action) => {
return {
...state,
roomInfo: {
...state.roomInfo,
roomName: action.res.roomName,
receiveAlarm: action.res.receiveAlarm
}
};
}),
2019-10-11 04:11:48 +00:00
on(AuthenticationStore.logout, (state, action) => {
return {
...initialState
};
2019-10-08 02:19:47 +00:00
})
);