From 78a6f133806b8431c7cdf2e1f184b1ce4c3c6147 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Mon, 9 Oct 2023 19:46:07 +0800 Subject: [PATCH] Fix leaked follow requests from Notifications popover to page --- src/pages/notifications.jsx | 70 ++++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 33 deletions(-) diff --git a/src/pages/notifications.jsx b/src/pages/notifications.jsx index 8c6b57bc..fb1a1393 100644 --- a/src/pages/notifications.jsx +++ b/src/pages/notifications.jsx @@ -379,39 +379,43 @@ function Notifications({ columnMode }) { )} {snapStates.notifications.length ? ( <> - {snapStates.notifications.map((notification) => { - if (onlyMentions && notification.type !== 'mention') { - return null; - } - const notificationDay = new Date(notification.createdAt); - const differentDay = - notificationDay.toDateString() !== currentDay.toDateString(); - if (differentDay) { - currentDay = notificationDay; - } - // if notificationDay is yesterday, show "Yesterday" - // if notificationDay is before yesterday, show date - const heading = - notificationDay.toDateString() === yesterdayDate.toDateString() - ? 'Yesterday' - : niceDateTime(currentDay, { - hideTime: true, - }); - return ( - <> - {differentDay &&

{heading}

} - { - loadNotifications(true); - loadFollowRequests(); - }} - /> - - ); - })} + {snapStates.notifications + // This is leaked from Notifications popover + .filter((n) => n.type !== 'follow_request') + .map((notification) => { + if (onlyMentions && notification.type !== 'mention') { + return null; + } + const notificationDay = new Date(notification.createdAt); + const differentDay = + notificationDay.toDateString() !== currentDay.toDateString(); + if (differentDay) { + currentDay = notificationDay; + } + // if notificationDay is yesterday, show "Yesterday" + // if notificationDay is before yesterday, show date + const heading = + notificationDay.toDateString() === + yesterdayDate.toDateString() + ? 'Yesterday' + : niceDateTime(currentDay, { + hideTime: true, + }); + return ( + <> + {differentDay &&

{heading}

} + { + loadNotifications(true); + loadFollowRequests(); + }} + /> + + ); + })} ) : ( <>