mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +07:00
loading comments
This commit is contained in:
parent
76a3331719
commit
398f44e232
5 changed files with 21 additions and 6 deletions
|
@ -12,7 +12,7 @@ export const nodeSetSaveErrors = (errors: IValidationErrors) => ({
|
|||
type: NODE_ACTIONS.SET_SAVE_ERRORS,
|
||||
});
|
||||
|
||||
export const nodeLoadNode = (id: string | number, node_type: INode['type']) => ({
|
||||
export const nodeLoadNode = (id: number, node_type: INode['type']) => ({
|
||||
id,
|
||||
node_type,
|
||||
type: NODE_ACTIONS.LOAD_NODE,
|
||||
|
|
|
@ -47,3 +47,13 @@ export const postNodeComment = ({
|
|||
.post(API.NODE.COMMENT(id), data, configWithToken(access))
|
||||
.then(resultMiddleware)
|
||||
.catch(errorMiddleware);
|
||||
|
||||
export const getNodeComments = ({
|
||||
id,
|
||||
}: {
|
||||
id: number;
|
||||
}): Promise<IResultWithStatus<{ comment: Comment }>> =>
|
||||
api
|
||||
.get(API.NODE.COMMENT(id))
|
||||
.then(resultMiddleware)
|
||||
.catch(errorMiddleware);
|
||||
|
|
|
@ -13,7 +13,7 @@ import {
|
|||
nodeSetSendingComment,
|
||||
nodeSetComments,
|
||||
} from './actions';
|
||||
import { postNode, getNode, postNodeComment } from './api';
|
||||
import { postNode, getNode, postNodeComment, getNodeComments } from './api';
|
||||
import { reqWrapper } from '../auth/sagas';
|
||||
import { flowSetNodes } from '../flow/actions';
|
||||
import { ERRORS } from '~/constants/errors';
|
||||
|
@ -65,7 +65,12 @@ function* onNodeLoad({ id, node_type }: ReturnType<typeof nodeLoadNode>) {
|
|||
yield put(nodeSetCurrent(node));
|
||||
|
||||
// todo: load comments
|
||||
yield delay(500);
|
||||
const {
|
||||
data: { comments },
|
||||
} = yield call(getNodeComments, { id });
|
||||
|
||||
yield put(nodeSetComments(comments || []));
|
||||
|
||||
yield put(nodeSetLoadingComments(false));
|
||||
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue