Rocket.Chat.ReactNative/app/reducers/settings.ts

27 lines
588 B
TypeScript
Raw Normal View History

2022-01-14 21:00:04 +00:00
import { IActionSettings } from '../actions/settings';
import { SETTINGS } from '../actions/actionsTypes';
2022-01-14 21:00:04 +00:00
// TODO UPDATE SETTINGS TYPE
export type ISettings = Record<string, any>;
2022-01-14 21:00:04 +00:00
export const initialState: ISettings = {};
export default (state = initialState, action: IActionSettings): ISettings => {
switch (action.type) {
case SETTINGS.ADD:
return {
...state,
...action.payload
};
case SETTINGS.UPDATE:
return {
...state,
[action.payload.id]: action.payload.value
};
case SETTINGS.CLEAR:
return initialState;
default:
return state;
}
};