2018-09-04 14:29:20 +00:00
|
|
|
import { SORT_PREFERENCES } from '../actions/actionsTypes';
|
2022-04-07 14:10:03 +00:00
|
|
|
import { DisplayMode, SortBy } from '../lib/constants';
|
2022-01-13 21:45:14 +00:00
|
|
|
import { IPreferences, TApplicationActions } from '../definitions';
|
2018-09-04 14:29:20 +00:00
|
|
|
|
2022-01-13 21:45:14 +00:00
|
|
|
export const initialState: IPreferences = {
|
2022-01-11 14:47:23 +00:00
|
|
|
sortBy: SortBy.Activity,
|
2018-12-05 20:52:08 +00:00
|
|
|
groupByType: false,
|
|
|
|
showFavorites: false,
|
2021-10-06 20:30:10 +00:00
|
|
|
showUnread: false,
|
|
|
|
showAvatar: true,
|
2022-01-11 14:47:23 +00:00
|
|
|
displayMode: DisplayMode.Expanded
|
2018-09-04 14:29:20 +00:00
|
|
|
};
|
|
|
|
|
2022-01-13 21:45:14 +00:00
|
|
|
export default (state = initialState, action: TApplicationActions): IPreferences => {
|
2018-09-04 14:29:20 +00:00
|
|
|
switch (action.type) {
|
|
|
|
case SORT_PREFERENCES.SET_ALL:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
...action.preferences
|
|
|
|
};
|
|
|
|
case SORT_PREFERENCES.SET:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
...action.preference
|
|
|
|
};
|
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
};
|