mirror of
https://github.com/elk-zone/elk.git
synced 2024-11-22 01:15:25 +03:00
fix(ui): exclude notifications without the status (#2375)
This commit is contained in:
parent
fee811dd75
commit
c8d9c4b871
1 changed files with 12 additions and 2 deletions
|
@ -13,6 +13,16 @@ const virtualScroller = false // TODO: fix flickering issue with virtual scroll
|
||||||
|
|
||||||
const groupCapacity = Number.MAX_VALUE // No limit
|
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)
|
// Group by type (and status when applicable)
|
||||||
function groupId(item: mastodon.v1.Notification): string {
|
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)
|
// 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)
|
results.push(...group)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const item of items) {
|
for (const item of items.filter(includeNotificationsForStatusCard)) {
|
||||||
const itemId = groupId(item)
|
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)
|
if (currentGroupId !== itemId || currentGroup.length >= groupCapacity)
|
||||||
processGroup()
|
processGroup()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue