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

35 lines
807 B
TypeScript

import { createReducer, on } from '@ngrx/store';
import { initialState } from './state';
import { infoSuccess, updateSuccess } from './actions';
import * as AuthenticationStore from '@app/store/account/authentication';
export const reducer = createReducer(
initialState,
on(infoSuccess, (state, action) => {
return {
...state,
roomInfo: action.roomInfo,
userInfoList: action.userInfoList,
userInfoShortList: action.userInfoShortList
};
}),
on(updateSuccess, (state, action) => {
return {
...state,
roomInfo: {
...state.roomInfo,
roomName: action.res.roomName,
receiveAlarm: action.res.receiveAlarm
}
};
}),
on(AuthenticationStore.logout, (state, action) => {
return {
...initialState
};
})
);