From b57f3a83059b9c086c1b3aec59e050d7c302c8eb Mon Sep 17 00:00:00 2001
From: tangjiang <465264938@qq.com>
Date: Wed, 25 Dec 2019 17:13:23 +0800
Subject: [PATCH] sync comment count
---
.../src/common/components/comment/index.scss | 2 +-
.../developer/studentStudy/leftpane/index.js | 4 ++--
public/react/src/redux/actions/actionTypes.js | 1 +
public/react/src/redux/actions/comment.js | 17 ++++++++++++++++-
.../src/redux/reducers/ojForUserReducer.js | 9 ++++++++-
5 files changed, 28 insertions(+), 5 deletions(-)
diff --git a/public/react/src/common/components/comment/index.scss b/public/react/src/common/components/comment/index.scss
index 067fc7e9a..41371e8cc 100644
--- a/public/react/src/common/components/comment/index.scss
+++ b/public/react/src/common/components/comment/index.scss
@@ -180,7 +180,7 @@ $ml: 20px;
background: #fff;
left: 0px;
right: 0px;
- top: -220px;
+ top: -250px;
padding: 0 20px;
}
}
\ No newline at end of file
diff --git a/public/react/src/modules/developer/studentStudy/leftpane/index.js b/public/react/src/modules/developer/studentStudy/leftpane/index.js
index d9527a13e..30eedea18 100644
--- a/public/react/src/modules/developer/studentStudy/leftpane/index.js
+++ b/public/react/src/modules/developer/studentStudy/leftpane/index.js
@@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-11-23 11:33:41
* @LastEditors : tangjiang
- * @LastEditTime : 2019-12-25 11:07:42
+ * @LastEditTime : 2019-12-25 17:10:30
// */
import './index.scss';
import React, { useState, useEffect, useMemo } from 'react';
@@ -129,7 +129,7 @@ const LeftPane = (props) => {
/>
-
+
{
if (res.status === 200) {
// 重新加载评论列表
dispatch(getCommentLists(identifier));
+ // 成功后,评论加一条
+ dispatch({
+ type: types.UPDATE_OJ_FOR_USER_COMMENT_COUNT,
+ payload: 'add' //
+ });
}
});
}
@@ -57,6 +62,11 @@ export const replayChildComment = (identifier, comment) => {
if (res.status === 200) {
// 重新加载评论列表
dispatch(getCommentLists(identifier));
+ // 成功后,评论加一条
+ dispatch({
+ type: types.UPDATE_OJ_FOR_USER_COMMENT_COUNT,
+ payload: 'add' //
+ });
}
});
}
@@ -69,6 +79,11 @@ export const deleteComment = (identifier, delId) => {
if (res.status === 200) {
// 重新加载评论列表
dispatch(getCommentLists(identifier));
+ // 成功后,评论加一条
+ dispatch({
+ type: types.UPDATE_OJ_FOR_USER_COMMENT_COUNT,
+ payload: 'minus' //
+ });
}
});
}
diff --git a/public/react/src/redux/reducers/ojForUserReducer.js b/public/react/src/redux/reducers/ojForUserReducer.js
index 8d82b8307..18ffd30c8 100644
--- a/public/react/src/redux/reducers/ojForUserReducer.js
+++ b/public/react/src/redux/reducers/ojForUserReducer.js
@@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-11-27 13:41:48
* @LastEditors : tangjiang
- * @LastEditTime : 2019-12-25 14:45:47
+ * @LastEditTime : 2019-12-25 17:09:53
*/
import types from "../actions/actionTypes";
import { Base64 } from 'js-base64';
@@ -211,6 +211,13 @@ const ojForUserReducer = (state = initialState, action) => {
...state,
pages: Object.assign({}, state.pages, { page: action.payload})
}
+ case types.UPDATE_OJ_FOR_USER_COMMENT_COUNT:
+ const {comments_count} = state.hack;
+ const _comments_count = action.payload === 'add' ? comments_count + 1 : comments_count - 1;
+ return {
+ ...state,
+ hack: Object.assign({}, state.hack, { comments_count: _comments_count })
+ }
default:
return state;
}