Skip to content

Commit

Permalink
fix(ui): exclude notifications without the status (#2375)
Browse files Browse the repository at this point in the history
  • Loading branch information
userquin committed Oct 9, 2023
1 parent fee811d commit c8d9c4b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions components/notification/NotificationPaginator.vue
Expand Up @@ -13,6 +13,16 @@ const virtualScroller = false // TODO: fix flickering issue with virtual scroll
const groupCapacity = Number.MAX_VALUE // No limit
const includeNotificationTypes: mastodon.v1.NotificationType[] = ['update', 'mention', 'poll', 'status']
function includeNotificationsForStatusCard({ type, status }: mastodon.v1.Notification) {
// Exclude update, mention, pool and status notifications without the status entry:
// no makes sense to include them
// Those notifications will be shown using StatusCard SFC:
// check NotificationCard SFC L68 and L81 => :status="notification.status!"
return status || !includeNotificationTypes.includes(type)
}
// Group by type (and status when applicable)
function groupId(item: mastodon.v1.Notification): string {
// If the update is related to an status, group notifications from the same account (boost + favorite the same status)
Expand Down Expand Up @@ -108,9 +118,9 @@ function groupItems(items: mastodon.v1.Notification[]): NotificationSlot[] {
results.push(...group)
}
for (const item of items) {
for (const item of items.filter(includeNotificationsForStatusCard)) {
const itemId = groupId(item)
// Finalize group if it already has too many notifications
// Finalize the group if it already has too many notifications
if (currentGroupId !== itemId || currentGroup.length >= groupCapacity)
processGroup()
Expand Down

0 comments on commit c8d9c4b

Please sign in to comment.