Skip to content

Commit

Permalink
Distinct both implementation of grouped notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
cheeaun committed Jul 21, 2024
1 parent b883765 commit a2b88f1
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
6 changes: 4 additions & 2 deletions src/components/notification.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,11 @@ function Notification({
report,
event,
moderation_warning,
// Client-side grouped notification
_ids,
_accounts,
_statuses,
// Grouped notification
// Server-side grouped notification
sampleAccounts,
notificationsCount,
} = notification;
Expand Down Expand Up @@ -266,7 +268,7 @@ function Notification({
return (
<div
class={`notification notification-${type}`}
data-notification-id={id}
data-notification-id={_ids || id}
tabIndex="0"
>
<div
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ function NotificationsMenu({ anchorRef, state, onClose }) {
.slice(0, NOTIFICATIONS_DISPLAY_LIMIT)
.map((notification) => (
<Notification
key={notification.ids || notification.id}
key={notification._ids || notification.id}
instance={instance}
notification={notification}
disableContextMenu
Expand Down
4 changes: 2 additions & 2 deletions src/pages/notifications.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -716,12 +716,12 @@ function Notifications({ columnMode }) {
hideTime: true,
});
return (
<Fragment key={notification.ids || notification.id}>
<Fragment key={notification._ids || notification.id}>
{differentDay && <h2 class="timeline-header">{heading}</h2>}
<Notification
instance={instance}
notification={notification}
key={notification.ids || notification.id}
key={notification._ids || notification.id}
/>
</Fragment>
);
Expand Down
14 changes: 7 additions & 7 deletions src/utils/group-notifications.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ export function groupNotifications2(groupNotifications) {
const mappedNotification = notificationsMap2[key];
if (mappedNotification) {
mappedNotification._statuses.push(gn.status);
mappedNotification.ids += `-${gn.id}`;
mappedNotification._ids += `-${gn.id}`;
} else {
let n = (notificationsMap2[key] = {
ids: gn.id,
...gn,
type,
_ids: gn.id,
_statuses: [gn.status],
});
newGroupNotifications2.push(n);
Expand Down Expand Up @@ -145,18 +145,18 @@ export default function groupNotifications(notifications) {
if (mappedAccount) {
mappedAccount._types.push(type);
mappedAccount._types.sort().reverse();
mappedNotification.ids += `-${id}`;
mappedNotification._ids += `-${id}`;
} else {
account._types = [type];
mappedNotification._accounts.push(account);
mappedNotification.ids += `-${id}`;
mappedNotification._ids += `-${id}`;
}
} else {
if (account) account._types = [type];
let n = (notificationsMap[key] = {
ids: id,
...notification,
type: virtualType,
_ids: id,
_accounts: account ? [account] : [],
});
cleanNotifications[j++] = n;
Expand All @@ -179,12 +179,12 @@ export default function groupNotifications(notifications) {
const mappedNotification = notificationsMap2[key];
if (mappedNotification) {
mappedNotification._statuses.push(notification.status);
mappedNotification.ids += `-${id}`;
mappedNotification._ids += `-${id}`;
} else {
let n = (notificationsMap2[key] = {
ids: id,
...notification,
type,
_ids: id,
_statuses: [notification.status],
});
cleanNotifications2[j++] = n;
Expand Down

0 comments on commit a2b88f1

Please sign in to comment.