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); const groupedNotifications = getGroupedNotifications(notifications);
states.notificationsLast = notifications[0]; states.notificationsLast = groupedNotifications[0];
states.notifications = groupedNotifications; states.notifications = groupedNotifications;
// Update last read marker // Update last read marker
masto.v1.markers masto.v1.markers
.create({ .create({
notifications: { notifications: {
lastReadId: notifications[0].id, lastReadId: groupedNotifications[0].id,
}, },
}) })
.catch(() => {}); .catch(() => {});
@ -177,7 +177,7 @@ function NotificationsMenu({ anchorRef, state, onClose }) {
.slice(0, NOTIFICATIONS_DISPLAY_LIMIT) .slice(0, NOTIFICATIONS_DISPLAY_LIMIT)
.map((notification) => ( .map((notification) => (
<Notification <Notification
key={notification.id} key={notification.ids || notification.id}
instance={instance} instance={instance}
notification={notification} notification={notification}
disableContextMenu disableContextMenu

View file

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

View file

@ -99,9 +99,10 @@ export function groupNotifications2(groupNotifications) {
const mappedNotification = notificationsMap2[key]; const mappedNotification = notificationsMap2[key];
if (mappedNotification) { if (mappedNotification) {
mappedNotification._statuses.push(gn.status); mappedNotification._statuses.push(gn.status);
mappedNotification.id += `-${gn.id}`; mappedNotification.ids += `-${gn.id}`;
} else { } else {
let n = (notificationsMap2[key] = { let n = (notificationsMap2[key] = {
ids: gn.id,
...gn, ...gn,
type, type,
_statuses: [gn.status], _statuses: [gn.status],
@ -144,15 +145,16 @@ export default function groupNotifications(notifications) {
if (mappedAccount) { if (mappedAccount) {
mappedAccount._types.push(type); mappedAccount._types.push(type);
mappedAccount._types.sort().reverse(); mappedAccount._types.sort().reverse();
mappedNotification.id += `-${id}`; mappedNotification.ids += `-${id}`;
} else { } else {
account._types = [type]; account._types = [type];
mappedNotification._accounts.push(account); mappedNotification._accounts.push(account);
mappedNotification.id += `-${id}`; mappedNotification.ids += `-${id}`;
} }
} else { } else {
if (account) account._types = [type]; if (account) account._types = [type];
let n = (notificationsMap[key] = { let n = (notificationsMap[key] = {
ids: id,
...notification, ...notification,
type: virtualType, type: virtualType,
_accounts: account ? [account] : [], _accounts: account ? [account] : [],
@ -177,9 +179,10 @@ export default function groupNotifications(notifications) {
const mappedNotification = notificationsMap2[key]; const mappedNotification = notificationsMap2[key];
if (mappedNotification) { if (mappedNotification) {
mappedNotification._statuses.push(notification.status); mappedNotification._statuses.push(notification.status);
mappedNotification.id += `-${id}`; mappedNotification.ids += `-${id}`;
} else { } else {
let n = (notificationsMap2[key] = { let n = (notificationsMap2[key] = {
ids: id,
...notification, ...notification,
type, type,
_statuses: [notification.status], _statuses: [notification.status],