forked from Mirrors/elk
refactor: use single filter logic
This commit is contained in:
parent
d3a567ddb8
commit
979c97306b
2 changed files with 6 additions and 20 deletions
|
@ -6,16 +6,9 @@ const { paginator } = defineProps<{
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
function preprocess(items: mastodon.v1.Conversation[]) {
|
function preprocess(items: mastodon.v1.Conversation[]) {
|
||||||
const filteredIndices = items.map(
|
return items.filter(items => !items.lastStatus?.filtered?.find(
|
||||||
(items, index) => (
|
filter => filter.filter.filterAction === 'hide' && filter.filter.context.includes('thread'),
|
||||||
{
|
))
|
||||||
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))
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -113,16 +113,9 @@ function groupItems(items: mastodon.v1.Notification[]): NotificationSlot[] {
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeFiltered(items: mastodon.v1.Notification[]): mastodon.v1.Notification[] {
|
function removeFiltered(items: mastodon.v1.Notification[]): mastodon.v1.Notification[] {
|
||||||
const filteredIndices = items.map(
|
return items.filter(item => !item.status?.filtered?.find(
|
||||||
(items, index) => (
|
filter => filter.filter.filterAction === 'hide' && filter.filter.context.includes('notifications'),
|
||||||
{
|
))
|
||||||
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))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function preprocess(items: NotificationSlot[]): NotificationSlot[] {
|
function preprocess(items: NotificationSlot[]): NotificationSlot[] {
|
||||||
|
|
Loading…
Reference in a new issue