From 06314a51a620188077fd324918cb26d89f9b0c07 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=BD=95=E7=AB=A5=E5=B4=87?= <792998983@qq.com>
Date: Wed, 15 Sep 2021 16:32:32 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=B0=8F=E9=93=83=E9=93=9B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/forge/Head/NoticeContent.jsx | 32 ++++++++++++++++++++++++++------
1 file changed, 26 insertions(+), 6 deletions(-)
diff --git a/src/forge/Head/NoticeContent.jsx b/src/forge/Head/NoticeContent.jsx
index 7092b545..965c9137 100644
--- a/src/forge/Head/NoticeContent.jsx
+++ b/src/forge/Head/NoticeContent.jsx
@@ -22,7 +22,6 @@ function NoticeContent({ visible, showNotification, resetUserInfo, current_user:
const [atUnreadCount, setAtUnreadCount] = useState();//未读@我数量
const [atPage, setAtPage] = useState(0);
const [atUnreadList, setAtUnreadList] = useState([]);//未读@我列表
- const [reload, setReload] = useState(0);
useEffect(() => {
const params = {
@@ -45,7 +44,7 @@ function NoticeContent({ visible, showNotification, resetUserInfo, current_user:
params.type = "atme"
}
visible && getMessageList(params);
- }, [reload, visible]);
+ }, [visible]);
function getMessageList(params) {
@@ -87,14 +86,33 @@ function NoticeContent({ visible, showNotification, resetUserInfo, current_user:
let data = response.data;
if (!data) return;
if (data.status === 0) {
- setReload(Math.random());
resetUserInfo();
+ changeReadMarkAll(noticeType);
} else {
showNotification(data.message);
}
});
}
+
+ function changeReadMarkAll(noticeType) {
+ if (noticeType === "notification") {
+ let list = noticeUnreadList.slice();
+ list.forEach(item => {
+ item.status = 2;
+ })
+ setNoticeUnreadList(list);
+ setNoticeUnreadCount(0);
+ } else if (noticeType === "atme") {
+ let list = atUnreadList.slice();
+ list.forEach(item => {
+ item.status = 2;
+ })
+ setAtUnreadList(list);
+ setAtUnreadCount(0);
+ }
+ }
+
// const [letter_unread_list, setLetter_unread_list] = useState([
// {
// id: 122,
@@ -123,6 +141,7 @@ function NoticeContent({ visible, showNotification, resetUserInfo, current_user:
});
}
+
function changeReadMark(item) {
if (item.type === "notification") {
let list = noticeUnreadList.slice();
@@ -169,7 +188,7 @@ function NoticeContent({ visible, showNotification, resetUserInfo, current_user: