feat: totally hide strict filters (#948)

This commit is contained in:
Ayo Ayco 2023-01-23 20:33:21 +01:00 committed by GitHub
parent 1a7ae6f0ef
commit a08f56676d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 82 additions and 33 deletions

View file

@ -112,6 +112,12 @@ function groupItems(items: mastodon.v1.Notification[]): NotificationSlot[] {
return results
}
function removeFiltered(items: mastodon.v1.Notification[]): mastodon.v1.Notification[] {
return items.filter(item => !item.status?.filtered?.find(
filter => filter.filter.filterAction === 'hide' && filter.filter.context.includes('notifications'),
))
}
function preprocess(items: NotificationSlot[]): NotificationSlot[] {
const flattenedNotifications: mastodon.v1.Notification[] = []
for (const item of items) {
@ -131,7 +137,7 @@ function preprocess(items: NotificationSlot[]): NotificationSlot[] {
flattenedNotifications.push(item)
}
}
return groupItems(flattenedNotifications)
return groupItems(removeFiltered(flattenedNotifications))
}
const { clearNotifications } = useNotifications()