1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 12:56:41 +07:00

fixed boris comments

This commit is contained in:
Fedor Katurov 2019-12-02 15:49:09 +07:00
parent 0e4c1acc3f
commit 5cb0791752
7 changed files with 163 additions and 90 deletions

View file

@ -39,8 +39,9 @@ export const nodeSetCurrent = (current: INodeState['current']) => ({
type: NODE_ACTIONS.SET_CURRENT,
});
export const nodePostComment = (id: number) => ({
export const nodePostComment = (id: number, is_before: boolean) => ({
id,
is_before,
type: NODE_ACTIONS.POST_COMMENT,
});

View file

@ -151,7 +151,7 @@ function* onNodeLoad({ id, order = 'ASC' }: ReturnType<typeof nodeLoadNode>) {
return;
}
function* onPostComment({ id }: ReturnType<typeof nodePostComment>) {
function* onPostComment({ id, is_before }: ReturnType<typeof nodePostComment>) {
const { current, comment_data } = yield select(selectNode);
yield put(nodeSetSendingComment(true));
@ -170,8 +170,13 @@ function* onPostComment({ id }: ReturnType<typeof nodePostComment>) {
if (current_node && current_node.id === current.id) {
// if user still browsing that node
const { comments } = yield select(selectNode);
yield put(nodeSetComments([...comments, comment]));
yield put(nodeSetCommentData(0, { ...EMPTY_COMMENT }));
if (is_before) {
yield put(nodeSetComments([comment, ...comments]));
} else {
yield put(nodeSetComments([...comments, comment]));
}
}
}