* 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
25 lines
628 B
TypeScript
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;
|
|
}
|
|
}
|