Browse Source

添加 tag 防止同一消息多次弹窗

visuddhinanda 2 years ago
parent
commit
dfb62b93fa
1 changed files with 2 additions and 0 deletions
  1. 2 0
      dashboard/src/components/notification/NotificationIcon.tsx

+ 2 - 0
dashboard/src/components/notification/NotificationIcon.tsx

@@ -10,6 +10,7 @@ const NotificationIconWidget = () => {
   useEffect(() => {
     let timer = setInterval(() => {
       const url = `/v2/notification?view=to&status=unread&limit=1`;
+      console.info("url", url);
       get<INotificationListResponse>(url).then((json) => {
         if (json.ok) {
           setCount(json.data.count);
@@ -25,6 +26,7 @@ const NotificationIconWidget = () => {
                     icon:
                       process.env.REACT_APP_API_HOST +
                       "/assets/images/wikipali_logo.png",
+                    tag: json.data.rows[0].id,
                   });
                   notification.onclick = (event) => {
                     event.preventDefault(); // 阻止浏览器聚焦于 Notification 的标签页