1
0
Fork 0

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.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 && <h2 class="timeline-header">{heading}</h2>}
<Notification
instance={instance}
notification={notification}
key={notification.id}
reload={() => {
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 && <h2 class="timeline-header">{heading}</h2>}
<Notification
instance={instance}
notification={notification}
key={notification.id}
reload={() => {
loadNotifications(true);
loadFollowRequests();
}}
/>
</>
);
})}
</>
) : (
<>