mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46:40 +07:00
41 lines
930 B
TypeScript
41 lines
930 B
TypeScript
import { createReducer } from '~/utils/reducer';
|
|
import { INode, IComment, IFile } from '../types';
|
|
import { EMPTY_NODE, EMPTY_COMMENT } from './constants';
|
|
import { NODE_HANDLERS } from './handlers';
|
|
|
|
export type INodeState = Readonly<{
|
|
editor: INode;
|
|
current: INode;
|
|
comments: IComment[];
|
|
comment_data: Record<number, IComment>;
|
|
current_cover_image: IFile;
|
|
|
|
error: string;
|
|
errors: Record<string, string>;
|
|
|
|
is_loading: boolean;
|
|
is_loading_comments: boolean;
|
|
is_sending_comment: boolean;
|
|
}>;
|
|
|
|
const INITIAL_STATE: INodeState = {
|
|
editor: {
|
|
...EMPTY_NODE,
|
|
type: 'image',
|
|
blocks: [],
|
|
files: [],
|
|
},
|
|
current: { ...EMPTY_NODE },
|
|
comment_data: { 0: { ...EMPTY_COMMENT } },
|
|
comments: [],
|
|
current_cover_image: null,
|
|
|
|
is_loading: false,
|
|
is_loading_comments: false,
|
|
is_sending_comment: false,
|
|
|
|
error: null,
|
|
errors: {},
|
|
};
|
|
|
|
export default createReducer(INITIAL_STATE, NODE_HANDLERS);
|