|
|
@@ -5,7 +5,10 @@ import { Image } from "@nutui/nutui-react-taro";
|
|
|
import { Message } from "@nutui/icons-react-taro";
|
|
|
import { useEffect, useState } from "react";
|
|
|
import CommentInput from "../../../components/comment-list/comment-input";
|
|
|
-import { getNotificationListApi } from "../../../api/notifications";
|
|
|
+import {
|
|
|
+ getNotificationListApi,
|
|
|
+ markAsReadByTypeApi,
|
|
|
+} from "../../../api/notifications";
|
|
|
const MessageList = () => {
|
|
|
const [showCommentInput, setShowCommentInput] = useState(false);
|
|
|
const [notificationList, setNotificationList] = useState<any[]>([]);
|
|
|
@@ -18,18 +21,21 @@ const MessageList = () => {
|
|
|
switch (options.type) {
|
|
|
case "like":
|
|
|
setTypeId("4,5");
|
|
|
+ handleReadNotification("4,5");
|
|
|
setNavigationBarTitle({
|
|
|
title: "收到的点赞",
|
|
|
});
|
|
|
break;
|
|
|
case "comment":
|
|
|
setTypeId("1,2,3");
|
|
|
+ handleReadNotification("1,2,3");
|
|
|
setNavigationBarTitle({
|
|
|
title: "评论和@",
|
|
|
});
|
|
|
break;
|
|
|
case "follow":
|
|
|
setTypeId("6,7");
|
|
|
+ handleReadNotification("6,7");
|
|
|
setNavigationBarTitle({
|
|
|
title: "关注和分享",
|
|
|
});
|
|
|
@@ -39,6 +45,12 @@ const MessageList = () => {
|
|
|
break;
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
+ // 标记消息类型通知为已读
|
|
|
+ const handleReadNotification = async (type_id) => {
|
|
|
+ markAsReadByTypeApi({ type_id });
|
|
|
+ };
|
|
|
+
|
|
|
const getNotificationList = async () => {
|
|
|
const res: any = await getNotificationListApi({
|
|
|
type_id: typeId,
|