feat: filter the notification statuses

This commit is contained in:
Ayo 2023-01-21 20:35:52 +01:00
parent a5c779aa2e
commit 50e0832310

View file

@ -131,7 +131,21 @@ function preprocess(items: NotificationSlot[]): NotificationSlot[] {
flattenedNotifications.push(item)
}
}
return groupItems(flattenedNotifications)
// extract indices of notifications with filtered statuses
const isStrict = (filter: mastodon.v1.FilterResult) => filter.filter.filterAction === 'hide' && filter.filter.context.includes('notifications')
const filteredIndices = flattenedNotifications
.map((item, index) => ({
status: item.status,
index,
}))
.filter(item => !item.status?.filtered?.find(isStrict))
.map(item => item.index)
// group the filtered elements given the indices
return groupItems(
flattenedNotifications.filter((item, index) => !filteredIndices.includes(index)),
)
}
const { clearNotifications } = useNotifications()