1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 21:06:42 +07:00

added boris route

This commit is contained in:
Fedor Katurov 2019-11-07 14:01:41 +07:00
parent c8ca961935
commit cf16cbf0f9
7 changed files with 70 additions and 13 deletions

View file

@ -12,9 +12,14 @@ export const nodeSetSaveErrors = (errors: IValidationErrors) => ({
type: NODE_ACTIONS.SET_SAVE_ERRORS,
});
export const nodeLoadNode = (id: number, node_type: INode['type']) => ({
export const nodeGotoNode = (id: number, node_type: INode['type']) => ({
id,
node_type,
type: NODE_ACTIONS.GOTO_NODE,
});
export const nodeLoadNode = (id: number) => ({
id,
type: NODE_ACTIONS.LOAD_NODE,
});

View file

@ -18,6 +18,7 @@ const prefix = 'NODE.';
export const NODE_ACTIONS = {
SAVE: `${prefix}SAVE`,
LOAD_NODE: `${prefix}LOAD_NODE`,
GOTO_NODE: `${prefix}GOTO_NODE`,
EDIT: `${prefix}EDIT`,
LIKE: `${prefix}LIKE`,

View file

@ -20,6 +20,7 @@ import {
nodeEdit,
nodeLike,
nodeSetRelated,
nodeGotoNode,
} from './actions';
import {
postNode,
@ -89,17 +90,19 @@ function* onNodeSave({ node }: ReturnType<typeof nodeSave>) {
return yield put(modalSetShown(false));
}
function* onNodeLoad({ id, node_type }: ReturnType<typeof nodeLoadNode>) {
function* onNodeGoto({ id, node_type }: ReturnType<typeof nodeGotoNode>) {
if (node_type) yield put(nodeSetCurrent({ ...EMPTY_NODE, type: node_type }));
yield put(nodeLoadNode(id));
yield put(push(URLS.NODE_URL(id)));
}
function* onNodeLoad({ id }: ReturnType<typeof nodeLoadNode>) {
yield put(nodeSetLoading(true));
yield put(nodeSetLoadingComments(true));
yield put(nodeSetSaveErrors({}));
yield put(nodeSetCommentData(0, { ...EMPTY_COMMENT }));
yield put(nodeSetRelated(null));
if (node_type) yield put(nodeSetCurrent({ ...EMPTY_NODE, type: node_type }));
yield put(push(URLS.NODE_URL(id)));
const {
data: { node, error },
} = yield call(reqWrapper, getNode, { id });
@ -113,7 +116,6 @@ function* onNodeLoad({ id, node_type }: ReturnType<typeof nodeLoadNode>) {
yield put(nodeSetSaveErrors({}));
yield put(nodeSetCurrent(node));
// todo: load comments
const {
comments: {
data: { comments },
@ -232,6 +234,7 @@ function* onStarSaga({ id }: ReturnType<typeof nodeLike>) {
export default function* nodeSaga() {
yield takeLatest(NODE_ACTIONS.SAVE, onNodeSave);
yield takeLatest(NODE_ACTIONS.GOTO_NODE, onNodeGoto);
yield takeLatest(NODE_ACTIONS.LOAD_NODE, onNodeLoad);
yield takeLatest(NODE_ACTIONS.POST_COMMENT, onPostComment);
yield takeLatest(NODE_ACTIONS.UPDATE_TAGS, onUpdateTags);