* 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
48 lines
1.1 KiB
TypeScript
48 lines
1.1 KiB
TypeScript
import { Node, Comment, CommentMode } from '@app/common/types';
|
|
|
|
import {
|
|
COMMENTS_SET,
|
|
COMMENTS_SET_ACTION,
|
|
PINNED_COMMENTS_SET_ACTION,
|
|
PINNED_COMMENTS_SET,
|
|
COMMENT_MODE_SET,
|
|
COMMENT_MODE_SET_ACTION,
|
|
} from './types';
|
|
|
|
export const comments = (state: Node[] = [], action: COMMENTS_SET_ACTION): Node[] => {
|
|
switch (action.type) {
|
|
case COMMENTS_SET: {
|
|
return action.comments;
|
|
}
|
|
default:
|
|
return state;
|
|
}
|
|
};
|
|
|
|
export type ActiveCommentState = null | { id: Comment['id']; state: CommentMode };
|
|
|
|
export const activeComment = (
|
|
state: ActiveCommentState = null,
|
|
action: COMMENT_MODE_SET_ACTION
|
|
): ActiveCommentState => {
|
|
switch (action.type) {
|
|
case COMMENT_MODE_SET: {
|
|
return action.mode;
|
|
}
|
|
default:
|
|
return state;
|
|
}
|
|
};
|
|
|
|
export const pinnedComments = (state: Comment[] = [], action: PINNED_COMMENTS_SET_ACTION): Comment[] => {
|
|
switch (action.type) {
|
|
case PINNED_COMMENTS_SET: {
|
|
return action.comments;
|
|
}
|
|
default:
|
|
return state;
|
|
}
|
|
};
|
|
|
|
export default { comments, activeComment, pinnedComments };
|