refactor: use single filter logic

This commit is contained in:
Ayo 2023-01-21 23:41:46 +01:00
parent d3a567ddb8
commit 979c97306b
2 changed files with 6 additions and 20 deletions

View file

@ -6,16 +6,9 @@ const { paginator } = defineProps<{
}>()
function preprocess(items: mastodon.v1.Conversation[]) {
const filteredIndices = items.map(
(items, index) => (
{
status: items.lastStatus,
index,
}))
.filter(item => !!item.status?.filtered?.find(filter => filter.filter.filterAction === 'hide' && filter.filter.context.includes('thread')))
.map(item => item.index)
return items.filter((_, index) => !filteredIndices.includes(index))
return items.filter(items => !items.lastStatus?.filtered?.find(
filter => filter.filter.filterAction === 'hide' && filter.filter.context.includes('thread'),
))
}
</script>

View file

@ -113,16 +113,9 @@ function groupItems(items: mastodon.v1.Notification[]): NotificationSlot[] {
}
function removeFiltered(items: mastodon.v1.Notification[]): mastodon.v1.Notification[] {
const filteredIndices = items.map(
(items, index) => (
{
status: items.status,
index,
}))
.filter(item => !!item.status?.filtered?.find(filter => filter.filter.filterAction === 'hide' && filter.filter.context.includes('notifications')))
.map(item => item.index)
return items.filter((_, index) => !filteredIndices.includes(index))
return items.filter(item => !item.status?.filtered?.find(
filter => filter.filter.filterAction === 'hide' && filter.filter.context.includes('notifications'),
))
}
function preprocess(items: NotificationSlot[]): NotificationSlot[] {