From 9bf77fa97a3fce53e06dc878d9e66c5ded3107fe Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Thu, 18 Apr 2024 17:15:51 +0800 Subject: [PATCH] Mentions also need fixNotifications It's also from notifications API --- src/pages/mentions.jsx | 3 +++ src/utils/group-notifications.jsx | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pages/mentions.jsx b/src/pages/mentions.jsx index d9bfe407..be816686 100644 --- a/src/pages/mentions.jsx +++ b/src/pages/mentions.jsx @@ -4,6 +4,7 @@ import { useSearchParams } from 'react-router-dom'; import Link from '../components/link'; import Timeline from '../components/timeline'; import { api } from '../utils/api'; +import { fixNotifications } from '../utils/group-notifications'; import { saveStatus } from '../utils/states'; import useTitle from '../utils/useTitle'; @@ -30,6 +31,8 @@ function Mentions({ columnMode, ...props }) { const results = await mentionsIterator.current.next(); let { value } = results; if (value?.length) { + value = fixNotifications(value); + if (firstLoad) { latestItem.current = value[0].id; console.log('First load', latestItem.current); diff --git a/src/utils/group-notifications.jsx b/src/utils/group-notifications.jsx index 630f2d4c..31e1b1c2 100644 --- a/src/utils/group-notifications.jsx +++ b/src/utils/group-notifications.jsx @@ -9,7 +9,7 @@ const notificationTypeKeys = { poll: ['status'], update: ['status'], }; -function fixNotifications(notifications) { +export function fixNotifications(notifications) { return notifications.filter((notification) => { const { type, id, createdAt } = notification; if (!type) {