From c8d9c4b87153daf28ab0d04c39f0076fd0cce032 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaqu=C3=ADn=20S=C3=A1nchez?= Date: Mon, 9 Oct 2023 22:33:02 +0200 Subject: [PATCH] fix(ui): exclude notifications without the status (#2375) --- components/notification/NotificationPaginator.vue | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/components/notification/NotificationPaginator.vue b/components/notification/NotificationPaginator.vue index 1c858d60..efb1354f 100644 --- a/components/notification/NotificationPaginator.vue +++ b/components/notification/NotificationPaginator.vue @@ -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) @@ -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()