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