mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-24 20:36:40 +07:00
loading comments
This commit is contained in:
parent
76a3331719
commit
398f44e232
5 changed files with 21 additions and 6 deletions
|
@ -38,8 +38,8 @@ const NodeLayoutUnconnected: FC<IProps> = ({
|
||||||
}) => {
|
}) => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (is_loading) return;
|
if (is_loading) return;
|
||||||
nodeLoadNode(id, null);
|
nodeLoadNode(parseInt(id, 10), null);
|
||||||
}, []);
|
}, [nodeLoadNode, id]);
|
||||||
|
|
||||||
const block = node && node.type && NODE_COMPONENTS[node.type] && NODE_COMPONENTS[node.type];
|
const block = node && node.type && NODE_COMPONENTS[node.type] && NODE_COMPONENTS[node.type];
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ export const nodeSetSaveErrors = (errors: IValidationErrors) => ({
|
||||||
type: NODE_ACTIONS.SET_SAVE_ERRORS,
|
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,
|
id,
|
||||||
node_type,
|
node_type,
|
||||||
type: NODE_ACTIONS.LOAD_NODE,
|
type: NODE_ACTIONS.LOAD_NODE,
|
||||||
|
|
|
@ -47,3 +47,13 @@ export const postNodeComment = ({
|
||||||
.post(API.NODE.COMMENT(id), data, configWithToken(access))
|
.post(API.NODE.COMMENT(id), data, configWithToken(access))
|
||||||
.then(resultMiddleware)
|
.then(resultMiddleware)
|
||||||
.catch(errorMiddleware);
|
.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,
|
nodeSetSendingComment,
|
||||||
nodeSetComments,
|
nodeSetComments,
|
||||||
} from './actions';
|
} from './actions';
|
||||||
import { postNode, getNode, postNodeComment } from './api';
|
import { postNode, getNode, postNodeComment, getNodeComments } from './api';
|
||||||
import { reqWrapper } from '../auth/sagas';
|
import { reqWrapper } from '../auth/sagas';
|
||||||
import { flowSetNodes } from '../flow/actions';
|
import { flowSetNodes } from '../flow/actions';
|
||||||
import { ERRORS } from '~/constants/errors';
|
import { ERRORS } from '~/constants/errors';
|
||||||
|
@ -65,7 +65,12 @@ function* onNodeLoad({ id, node_type }: ReturnType<typeof nodeLoadNode>) {
|
||||||
yield put(nodeSetCurrent(node));
|
yield put(nodeSetCurrent(node));
|
||||||
|
|
||||||
// todo: load comments
|
// todo: load comments
|
||||||
yield delay(500);
|
const {
|
||||||
|
data: { comments },
|
||||||
|
} = yield call(getNodeComments, { id });
|
||||||
|
|
||||||
|
yield put(nodeSetComments(comments || []));
|
||||||
|
|
||||||
yield put(nodeSetLoadingComments(false));
|
yield put(nodeSetLoadingComments(false));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -32,7 +32,7 @@ $text_sign: 22px;
|
||||||
$input_bg_color: darken($content_bg, 2%);
|
$input_bg_color: darken($content_bg, 2%);
|
||||||
$button_bg_color: $red_gradient;
|
$button_bg_color: $red_gradient;
|
||||||
|
|
||||||
$comment_bg: lighten($main_bg_color, 0%);
|
$comment_bg: lighten($content_bg, 2%);
|
||||||
$panel_bg: transparent;
|
$panel_bg: transparent;
|
||||||
$node_bg: darken($content_bg, 4%);
|
$node_bg: darken($content_bg, 4%);
|
||||||
$node_image_bg: darken($main_bg_color, 2%);
|
$node_image_bg: darken($main_bg_color, 2%);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue