1
This commit is contained in:
@@ -64,11 +64,17 @@ const MessagePageContent: React.FC<MessagePageContentProps> = ({ isActive = true
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 只有当页面激活且未加载过数据时才加载接口
|
// 当切换到消息 tab 时,调用红点信息接口
|
||||||
|
useEffect(() => {
|
||||||
|
if (isActive) {
|
||||||
|
fetchReddotInfo();
|
||||||
|
}
|
||||||
|
}, [isActive]);
|
||||||
|
|
||||||
|
// 只有当页面激活且未加载过数据时才加载通知列表
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isActive && !hasLoaded) {
|
if (isActive && !hasLoaded) {
|
||||||
getNoticeList();
|
getNoticeList();
|
||||||
fetchReddotInfo();
|
|
||||||
setHasLoaded(true);
|
setHasLoaded(true);
|
||||||
}
|
}
|
||||||
}, [isActive, hasLoaded]);
|
}, [isActive, hasLoaded]);
|
||||||
|
|||||||
@@ -71,14 +71,12 @@ const CommentReply = () => {
|
|||||||
|
|
||||||
setCommentList(mappedList);
|
setCommentList(mappedList);
|
||||||
|
|
||||||
// 获取未读评论ID并标记已读
|
// 获取所有评论ID列表并标记已读(传入所有ID,包括已读和未读)
|
||||||
const unreadIds = res.data.rows
|
const allCommentIds = res.data.rows.map((item: any) => item.id);
|
||||||
.filter((item: any) => item.is_read === 0)
|
|
||||||
.map((item: any) => item.id);
|
|
||||||
|
|
||||||
if (unreadIds.length > 0) {
|
if (allCommentIds.length > 0) {
|
||||||
// 使用统一接口标记已读
|
// 使用统一接口标记已读,传入所有评论ID
|
||||||
messageService.markAsRead('comment', unreadIds).catch(e => {
|
messageService.markAsRead('comment', allCommentIds).catch(e => {
|
||||||
console.error("标记评论已读失败:", e);
|
console.error("标记评论已读失败:", e);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -217,6 +215,15 @@ const CommentReply = () => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
setCommentList(mappedList);
|
setCommentList(mappedList);
|
||||||
|
|
||||||
|
// 获取所有评论ID列表并标记已读(传入所有ID)
|
||||||
|
const allCommentIds = res.data.rows.map((item: any) => item.id);
|
||||||
|
|
||||||
|
if (allCommentIds.length > 0) {
|
||||||
|
messageService.markAsRead('comment', allCommentIds).catch(e => {
|
||||||
|
console.error("标记评论已读失败:", e);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
|
|||||||
@@ -56,14 +56,12 @@ const NewFollow = () => {
|
|||||||
|
|
||||||
setFollowList(mappedList);
|
setFollowList(mappedList);
|
||||||
|
|
||||||
// 获取未读关注ID并标记已读
|
// 获取所有关注者ID列表并标记已读(传入所有ID,包括已读和未读)
|
||||||
const unreadFanIds = res.list
|
const allFanIds = res.list.map((item: any) => item.id);
|
||||||
.filter((item: any) => item.is_read === 0)
|
|
||||||
.map((item: any) => item.id);
|
|
||||||
|
|
||||||
if (unreadFanIds.length > 0) {
|
if (allFanIds.length > 0) {
|
||||||
// 使用统一接口标记已读
|
// 使用统一接口标记已读,传入所有关注者ID
|
||||||
messageService.markAsRead('follow', unreadFanIds).catch(e => {
|
messageService.markAsRead('follow', allFanIds).catch(e => {
|
||||||
console.error("标记关注已读失败:", e);
|
console.error("标记关注已读失败:", e);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -164,6 +162,15 @@ const NewFollow = () => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
setFollowList(mappedList);
|
setFollowList(mappedList);
|
||||||
|
|
||||||
|
// 获取所有关注者ID列表并标记已读(传入所有ID)
|
||||||
|
const allFanIds = res.list.map((item: any) => item.id);
|
||||||
|
|
||||||
|
if (allFanIds.length > 0) {
|
||||||
|
messageService.markAsRead('follow', allFanIds).catch(e => {
|
||||||
|
console.error("标记关注已读失败:", e);
|
||||||
|
});
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// 如果没有数据,设置为空数组以显示空状态
|
// 如果没有数据,设置为空数组以显示空状态
|
||||||
setFollowList([]);
|
setFollowList([]);
|
||||||
|
|||||||
Reference in New Issue
Block a user