verdnatura-chat/app/reducers/sortPreferences.ts

30 lines
714 B
TypeScript
Raw Permalink Normal View History

import { SORT_PREFERENCES } from '../actions/actionsTypes';
import { DisplayMode, SortBy } from '../constants/constantDisplayMode';
import { IPreferences, TApplicationActions } from '../definitions';
export const initialState: IPreferences = {
sortBy: SortBy.Activity,
2018-12-05 20:52:08 +00:00
groupByType: false,
showFavorites: false,
showUnread: false,
showAvatar: true,
displayMode: DisplayMode.Expanded
};
export default (state = initialState, action: TApplicationActions): IPreferences => {
switch (action.type) {
case SORT_PREFERENCES.SET_ALL:
return {
...state,
...action.preferences
};
case SORT_PREFERENCES.SET:
return {
...state,
...action.preference
};
default:
return state;
}
};