diff --git a/app/javascript/mastodon/features/notifications_v2/components/avatar_group.tsx b/app/javascript/mastodon/features/notifications_v2/components/avatar_group.tsx index 741938f62b..e1e25810d3 100644 --- a/app/javascript/mastodon/features/notifications_v2/components/avatar_group.tsx +++ b/app/javascript/mastodon/features/notifications_v2/components/avatar_group.tsx @@ -1,6 +1,7 @@ import { Link } from 'react-router-dom'; import { Avatar } from 'mastodon/components/avatar'; +import { NOTIFICATIONS_GROUP_MAX_AVATARS } from 'mastodon/models/notification_group'; import { useAppSelector } from 'mastodon/store'; const AvatarWrapper: React.FC<{ accountId: string }> = ({ accountId }) => { @@ -19,7 +20,7 @@ export const AvatarGroup: React.FC<{ accountIds: string[] }> = ({ accountIds, }) => (
- {accountIds.slice(0, 7).map((accountId) => ( + {accountIds.slice(0, NOTIFICATIONS_GROUP_MAX_AVATARS).map((accountId) => ( ))}
diff --git a/app/javascript/mastodon/models/notification_group.ts b/app/javascript/mastodon/models/notification_group.ts index c8e078c747..4dc7229c31 100644 --- a/app/javascript/mastodon/models/notification_group.ts +++ b/app/javascript/mastodon/models/notification_group.ts @@ -9,6 +9,10 @@ import type { } from 'mastodon/api_types/notifications'; import type { ApiReportJSON } from 'mastodon/api_types/reports'; +// Maximum number of avatars displayed in a notification group +// This corresponds to the max lenght of `group.sampleAccountsIds` +export const NOTIFICATIONS_GROUP_MAX_AVATARS = 6; + interface BaseNotificationGroup extends Omit { sampleAccountsIds: string[]; diff --git a/app/javascript/mastodon/reducers/notifications_groups.ts b/app/javascript/mastodon/reducers/notifications_groups.ts index e42d753958..de4bab5afe 100644 --- a/app/javascript/mastodon/reducers/notifications_groups.ts +++ b/app/javascript/mastodon/reducers/notifications_groups.ts @@ -6,6 +6,7 @@ import { processNewNotificationForGroups, } from 'mastodon/actions/notification_groups'; import { + NOTIFICATIONS_GROUP_MAX_AVATARS, createNotificationGroupFromJSON, createNotificationGroupFromNotificationJSON, } from 'mastodon/models/notification_group'; @@ -84,8 +85,11 @@ export const notificationsGroupsReducer = if (existingGroup && existingGroup.type !== 'gap') { // Update the existing group - existingGroup.sampleAccountsIds.unshift(notification.account.id); - existingGroup.sampleAccountsIds.pop(); + if ( + existingGroup.sampleAccountsIds.unshift(notification.account.id) > + NOTIFICATIONS_GROUP_MAX_AVATARS + ) + existingGroup.sampleAccountsIds.pop(); existingGroup.most_recent_notification_id = notification.id; existingGroup.page_max_id = notification.id;