From 00e2ba0b343da1d1a7ce96834a2a450ede83e549 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Sun, 21 Jul 2024 18:59:38 +0800 Subject: [PATCH] Fix notification markers not working Also the ids are getting confusing, so need to clean this up. --- src/pages/home.jsx | 6 +++--- src/pages/notifications.jsx | 6 +++--- src/utils/group-notifications.jsx | 11 +++++++---- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/pages/home.jsx b/src/pages/home.jsx index 75ac78c0..a9160737 100644 --- a/src/pages/home.jsx +++ b/src/pages/home.jsx @@ -109,14 +109,14 @@ function NotificationsMenu({ anchorRef, state, onClose }) { const groupedNotifications = getGroupedNotifications(notifications); - states.notificationsLast = notifications[0]; + states.notificationsLast = groupedNotifications[0]; states.notifications = groupedNotifications; // Update last read marker masto.v1.markers .create({ notifications: { - lastReadId: notifications[0].id, + lastReadId: groupedNotifications[0].id, }, }) .catch(() => {}); @@ -177,7 +177,7 @@ function NotificationsMenu({ anchorRef, state, onClose }) { .slice(0, NOTIFICATIONS_DISPLAY_LIMIT) .map((notification) => ( {}); @@ -716,12 +716,12 @@ function Notifications({ columnMode }) { hideTime: true, }); return ( - + {differentDay &&

{heading}

}
); diff --git a/src/utils/group-notifications.jsx b/src/utils/group-notifications.jsx index 80e8390e..3390bd84 100644 --- a/src/utils/group-notifications.jsx +++ b/src/utils/group-notifications.jsx @@ -99,9 +99,10 @@ export function groupNotifications2(groupNotifications) { const mappedNotification = notificationsMap2[key]; if (mappedNotification) { mappedNotification._statuses.push(gn.status); - mappedNotification.id += `-${gn.id}`; + mappedNotification.ids += `-${gn.id}`; } else { let n = (notificationsMap2[key] = { + ids: gn.id, ...gn, type, _statuses: [gn.status], @@ -144,15 +145,16 @@ export default function groupNotifications(notifications) { if (mappedAccount) { mappedAccount._types.push(type); mappedAccount._types.sort().reverse(); - mappedNotification.id += `-${id}`; + mappedNotification.ids += `-${id}`; } else { account._types = [type]; mappedNotification._accounts.push(account); - mappedNotification.id += `-${id}`; + mappedNotification.ids += `-${id}`; } } else { if (account) account._types = [type]; let n = (notificationsMap[key] = { + ids: id, ...notification, type: virtualType, _accounts: account ? [account] : [], @@ -177,9 +179,10 @@ export default function groupNotifications(notifications) { const mappedNotification = notificationsMap2[key]; if (mappedNotification) { mappedNotification._statuses.push(notification.status); - mappedNotification.id += `-${id}`; + mappedNotification.ids += `-${id}`; } else { let n = (notificationsMap2[key] = { + ids: id, ...notification, type, _statuses: [notification.status],