From 50e08323108b9426c87422bb070354763fc5f9cc Mon Sep 17 00:00:00 2001 From: Ayo Date: Sat, 21 Jan 2023 20:35:52 +0100 Subject: [PATCH] feat: filter the notification statuses --- .../notification/NotificationPaginator.vue | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/components/notification/NotificationPaginator.vue b/components/notification/NotificationPaginator.vue index c6c3b531..5b3d7a3a 100644 --- a/components/notification/NotificationPaginator.vue +++ b/components/notification/NotificationPaginator.vue @@ -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()