mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +07:00
removed node reducer
This commit is contained in:
parent
168ba8cc04
commit
8d2b56cafc
14 changed files with 62 additions and 208 deletions
|
@ -1,7 +0,0 @@
|
|||
import { IFile } from '../types';
|
||||
import { NODE_ACTIONS } from './constants';
|
||||
|
||||
export const nodeSetCoverImage = (current_cover_image?: IFile) => ({
|
||||
type: NODE_ACTIONS.SET_COVER_IMAGE,
|
||||
current_cover_image,
|
||||
});
|
|
@ -23,11 +23,6 @@ import { LabDescription } from '~/components/lab/LabDescription';
|
|||
import { LabVideo } from '~/components/lab/LabVideo';
|
||||
import { LabAudio } from '~/components/lab/LabAudioBlock';
|
||||
|
||||
const prefix = 'NODE.';
|
||||
export const NODE_ACTIONS = {
|
||||
SET_COVER_IMAGE: `${prefix}SET_COVER_IMAGE`,
|
||||
};
|
||||
|
||||
export const EMPTY_NODE: INode = {
|
||||
id: 0,
|
||||
user: undefined,
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
import { assocPath } from 'ramda';
|
||||
import { NODE_ACTIONS } from './constants';
|
||||
import { nodeSetCoverImage } from './actions';
|
||||
import { INodeState } from './reducer';
|
||||
|
||||
const setCoverImage = (
|
||||
state: INodeState,
|
||||
{ current_cover_image }: ReturnType<typeof nodeSetCoverImage>
|
||||
) => assocPath(['current_cover_image'], current_cover_image, state);
|
||||
|
||||
export const NODE_HANDLERS = {
|
||||
[NODE_ACTIONS.SET_COVER_IMAGE]: setCoverImage,
|
||||
};
|
|
@ -1,42 +0,0 @@
|
|||
import { createReducer } from '~/utils/reducer';
|
||||
import { IComment, IFile, INode } from '../types';
|
||||
import { EMPTY_NODE } from './constants';
|
||||
import { NODE_HANDLERS } from './handlers';
|
||||
|
||||
export type INodeState = Readonly<{
|
||||
editor: INode;
|
||||
current: INode;
|
||||
comments: IComment[];
|
||||
lastSeenCurrent?: string;
|
||||
comment_count: number;
|
||||
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_count: 0,
|
||||
comments: [],
|
||||
current_cover_image: undefined,
|
||||
|
||||
is_loading: false,
|
||||
is_loading_comments: false,
|
||||
is_sending_comment: false,
|
||||
|
||||
error: '',
|
||||
errors: {},
|
||||
};
|
||||
|
||||
export default createReducer(INITIAL_STATE, NODE_HANDLERS);
|
|
@ -1,3 +0,0 @@
|
|||
import { IState } from '../store';
|
||||
|
||||
export const selectNode = (state: IState) => state.node;
|
|
@ -11,8 +11,6 @@ import auth from '~/redux/auth';
|
|||
import authSaga from '~/redux/auth/sagas';
|
||||
import { IAuthState } from '~/redux/auth/types';
|
||||
|
||||
import node, { INodeState } from '~/redux/node/reducer';
|
||||
|
||||
import flow, { IFlowState } from '~/redux/flow/reducer';
|
||||
import flowSaga from '~/redux/flow/sagas';
|
||||
|
||||
|
@ -65,7 +63,6 @@ export interface IState {
|
|||
auth: IAuthState;
|
||||
modal: IModalState;
|
||||
router: RouterState;
|
||||
node: INodeState;
|
||||
uploads: IUploadState;
|
||||
flow: IFlowState;
|
||||
player: IPlayerState;
|
||||
|
@ -91,7 +88,6 @@ export const store = createStore(
|
|||
modal,
|
||||
boris,
|
||||
router: connectRouter(history),
|
||||
node,
|
||||
uploads,
|
||||
flow: persistReducer(flowPersistConfig, flow),
|
||||
player: persistReducer(playerPersistConfig, player),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue