Files
remark42/frontend/app/store/thread/reducers.ts
T
Misha VyrtsevandUmputun 3b4628d0bd Auth login design (#390)
* break auth panel render into submethods

* move var definition

* break renderUnathorized into submethods

* hide login providers behind dropdown if they are exceed length of 3

* amend dropdown to behave nicely being placed in another dropdown

* add style to providers enclosed in dropdown

* add provider reducer and actions

* add provider save/restore to app flow

* place last login provider first in providers list

* infer StoreState from combineReducers return type

* move collapsed threads retoration to action

* fix: provider lost in other

* add dynamic threshold depending on window width

* fix & add tests
2019-07-25 22:54:59 -05:00

29 lines
673 B
TypeScript

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<CollapsedThreadsState>((acc, id) => {
acc[id] = true;
return acc;
}, {});
}
case THREAD_SET_COLLAPSE: {
return {
...state,
[action.id]: action.collapsed,
};
}
default:
return state;
}
};
export default {
collapsedThreads,
};