Fix notification markers not working

Also the ids are getting confusing, so need to clean this up.
This commit is contained in:
Lim Chee Aun 2024-07-21 18:59:38 +08:00
parent a0d75e7e83
commit 00e2ba0b34
3 changed files with 13 additions and 10 deletions

View file

@ -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) => (
<Notification
key={notification.id}
key={notification.ids || notification.id}
instance={instance}
notification={notification}
disableContextMenu

View file

@ -165,7 +165,7 @@ function Notifications({ columnMode }) {
masto.v1.markers
.create({
notifications: {
lastReadId: notifications[0].id,
lastReadId: groupedNotifications[0].id,
},
})
.catch(() => {});
@ -716,12 +716,12 @@ function Notifications({ columnMode }) {
hideTime: true,
});
return (
<Fragment key={notification.id}>
<Fragment key={notification.ids || notification.id}>
{differentDay && <h2 class="timeline-header">{heading}</h2>}
<Notification
instance={instance}
notification={notification}
key={notification.id}
key={notification.ids || notification.id}
/>
</Fragment>
);

View file

@ -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],