sync comment count

yslnewtiku
tangjiang 5 years ago
parent baa7c41a71
commit b57f3a8305

@ -180,7 +180,7 @@ $ml: 20px;
background: #fff; background: #fff;
left: 0px; left: 0px;
right: 0px; right: 0px;
top: -220px; top: -250px;
padding: 0 20px; padding: 0 20px;
} }
} }

@ -4,7 +4,7 @@
* @Github: * @Github:
* @Date: 2019-11-23 11:33:41 * @Date: 2019-11-23 11:33:41
* @LastEditors : tangjiang * @LastEditors : tangjiang
* @LastEditTime : 2019-12-25 11:07:42 * @LastEditTime : 2019-12-25 17:10:30
// */ // */
import './index.scss'; import './index.scss';
import React, { useState, useEffect, useMemo } from 'react'; import React, { useState, useEffect, useMemo } from 'react';
@ -129,7 +129,7 @@ const LeftPane = (props) => {
/> />
</div> </div>
<div className="number_flex flex_info"> <div className="number_flex flex_info">
<TextNumber text="huifu1" number={comments_count} type="icon" onIconClick={handleClickMessage}/> <TextNumber text="huifu1" number={hack.comments_count} type="icon" onIconClick={handleClickMessage}/>
<TextNumber <TextNumber
className={user_praise ? 'like active' : 'like'} className={user_praise ? 'like active' : 'like'}
text="dianzan" text="dianzan"

@ -56,6 +56,7 @@ const types = {
CLEAR_OJ_FOR_USER_REDUCER: 'CLEAR_OJ_FOR_USER_REDUCER', // 退出时清空 ojForUserReducer保存内容 CLEAR_OJ_FOR_USER_REDUCER: 'CLEAR_OJ_FOR_USER_REDUCER', // 退出时清空 ojForUserReducer保存内容
ADD_OJ_LIKE_COUNT: 'ADD_OJ_LIKE_COUNT', // 增加点赞数 ADD_OJ_LIKE_COUNT: 'ADD_OJ_LIKE_COUNT', // 增加点赞数
CHANGE_RECORD_PAGINATION_PAGE: 'CHANGE_RECORD_PAGINATION_PAGE', // 改变提交分页 CHANGE_RECORD_PAGINATION_PAGE: 'CHANGE_RECORD_PAGINATION_PAGE', // 改变提交分页
UPDATE_OJ_FOR_USER_COMMENT_COUNT: 'UPDATE_OJ_FOR_USER_COMMENT_COUNT', // 更新 hack 中的评论数
/*** jupyter */ /*** jupyter */
GET_JUPYTER_DATA_SETS: 'GET_JUPYTER_DATA_SETS', // jupyter 数据集 GET_JUPYTER_DATA_SETS: 'GET_JUPYTER_DATA_SETS', // jupyter 数据集
GET_JUPYTER_TPI_URL: 'GET_JUPYTER_TPI_URL', // 获取 jupyter url GET_JUPYTER_TPI_URL: 'GET_JUPYTER_TPI_URL', // 获取 jupyter url

@ -4,7 +4,7 @@
* @Github: * @Github:
* @Date: 2019-12-23 10:53:25 * @Date: 2019-12-23 10:53:25
* @LastEditors : tangjiang * @LastEditors : tangjiang
* @LastEditTime : 2019-12-25 10:55:27 * @LastEditTime : 2019-12-25 17:06:57
*/ */
import types from "./actionTypes"; import types from "./actionTypes";
@ -24,6 +24,11 @@ export const addComment = (identifier, comments) => {
if (res.status === 200) { if (res.status === 200) {
// 重新加载评论列表 // 重新加载评论列表
dispatch(getCommentLists(identifier)); 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) { if (res.status === 200) {
// 重新加载评论列表 // 重新加载评论列表
dispatch(getCommentLists(identifier)); 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) { if (res.status === 200) {
// 重新加载评论列表 // 重新加载评论列表
dispatch(getCommentLists(identifier)); dispatch(getCommentLists(identifier));
// 成功后,评论加一条
dispatch({
type: types.UPDATE_OJ_FOR_USER_COMMENT_COUNT,
payload: 'minus' //
});
} }
}); });
} }

@ -4,7 +4,7 @@
* @Github: * @Github:
* @Date: 2019-11-27 13:41:48 * @Date: 2019-11-27 13:41:48
* @LastEditors : tangjiang * @LastEditors : tangjiang
* @LastEditTime : 2019-12-25 14:45:47 * @LastEditTime : 2019-12-25 17:09:53
*/ */
import types from "../actions/actionTypes"; import types from "../actions/actionTypes";
import { Base64 } from 'js-base64'; import { Base64 } from 'js-base64';
@ -211,6 +211,13 @@ const ojForUserReducer = (state = initialState, action) => {
...state, ...state,
pages: Object.assign({}, state.pages, { page: action.payload}) 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: default:
return state; return state;
} }

Loading…
Cancel
Save