Files
remark42/frontend/app/store/thread/reducers.ts
T
Pavel MineevandUmputun 5825a55b69 Update frontend
* change root dit and change way to import modules
* update deps to latest versions
* use latest tools for building bundles
* rewrite webpack config
* use nomodule technique for loading modern bundle
* inject polyfills by babel usebuiltins
* update eslint rules
* rename all style files to CSS
* use postcss preset env for building styles
* proper typescript typing
* put all html files to templates folder
* etc
2021-01-12 13:39:26 -06:00

25 lines
628 B
TypeScript

import { THREAD_SET_COLLAPSE, THREAD_ACTIONS, THREAD_RESTORE_COLLAPSE } from './types';
export interface CollapsedThreadsState {
[key: string]: boolean;
}
export function collapsedThreads(state: CollapsedThreadsState = {}, action: THREAD_ACTIONS): CollapsedThreadsState {
switch (action.type) {
case THREAD_RESTORE_COLLAPSE: {
return action.ids.reduce<CollapsedThreadsState>((acc, id) => {
acc[id] = true;
return acc;
}, {});
}
case THREAD_SET_COLLAPSE: {
return {
...state,
[action.id]: action.collapsed,
};
}
default:
return state;
}
}