Skip to content

Commit

Permalink
Fix notification markers not working
Browse files Browse the repository at this point in the history
Also the ids are getting confusing, so need to clean this up.
  • Loading branch information
cheeaun committed Jul 21, 2024
1 parent a0d75e7 commit 00e2ba0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/pages/home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {});
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/pages/notifications.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ function Notifications({ columnMode }) {
masto.v1.markers
.create({
notifications: {
lastReadId: notifications[0].id,
lastReadId: groupedNotifications[0].id,
},
})
.catch(() => {});
Expand Down Expand Up @@ -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>
);
Expand Down
11 changes: 7 additions & 4 deletions src/utils/group-notifications.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down Expand Up @@ -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] : [],
Expand All @@ -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],
Expand Down

0 comments on commit 00e2ba0

Please sign in to comment.