Fix leaked follow requests from Notifications popover to page

This commit is contained in:
Lim Chee Aun 2023-10-09 19:46:07 +08:00
parent a697fb04df
commit 78a6f13380

View file

@ -379,39 +379,43 @@ function Notifications({ columnMode }) {
)} )}
{snapStates.notifications.length ? ( {snapStates.notifications.length ? (
<> <>
{snapStates.notifications.map((notification) => { {snapStates.notifications
if (onlyMentions && notification.type !== 'mention') { // This is leaked from Notifications popover
return null; .filter((n) => n.type !== 'follow_request')
} .map((notification) => {
const notificationDay = new Date(notification.createdAt); if (onlyMentions && notification.type !== 'mention') {
const differentDay = return null;
notificationDay.toDateString() !== currentDay.toDateString(); }
if (differentDay) { const notificationDay = new Date(notification.createdAt);
currentDay = notificationDay; const differentDay =
} notificationDay.toDateString() !== currentDay.toDateString();
// if notificationDay is yesterday, show "Yesterday" if (differentDay) {
// if notificationDay is before yesterday, show date currentDay = notificationDay;
const heading = }
notificationDay.toDateString() === yesterdayDate.toDateString() // if notificationDay is yesterday, show "Yesterday"
? 'Yesterday' // if notificationDay is before yesterday, show date
: niceDateTime(currentDay, { const heading =
hideTime: true, notificationDay.toDateString() ===
}); yesterdayDate.toDateString()
return ( ? 'Yesterday'
<> : niceDateTime(currentDay, {
{differentDay && <h2 class="timeline-header">{heading}</h2>} hideTime: true,
<Notification });
instance={instance} return (
notification={notification} <>
key={notification.id} {differentDay && <h2 class="timeline-header">{heading}</h2>}
reload={() => { <Notification
loadNotifications(true); instance={instance}
loadFollowRequests(); notification={notification}
}} key={notification.id}
/> reload={() => {
</> loadNotifications(true);
); loadFollowRequests();
})} }}
/>
</>
);
})}
</> </>
) : ( ) : (
<> <>