From 0fbe34c1e88d35923cc9e8cfaac68f5309fa8fa4 Mon Sep 17 00:00:00 2001 From: Ayo Ayco Date: Sun, 5 Feb 2023 16:05:42 +0100 Subject: [PATCH] fix: filter and cw logic (#1633) --- .../conversation/ConversationPaginator.vue | 3 +- components/status/StatusContent.vue | 16 +++++--- composables/timeline.ts | 2 +- tests/unit/reorder-timeline.test.ts | 37 +++++++++++++++---- 4 files changed, 42 insertions(+), 16 deletions(-) diff --git a/components/conversation/ConversationPaginator.vue b/components/conversation/ConversationPaginator.vue index e41292c4..d422f574 100644 --- a/components/conversation/ConversationPaginator.vue +++ b/components/conversation/ConversationPaginator.vue @@ -6,7 +6,8 @@ const { paginator } = defineProps<{ }>() function preprocess(items: mastodon.v1.Conversation[]): mastodon.v1.Conversation[] { - return items.filter(items => !items.lastStatus?.filtered?.find( + const isAuthored = (conversation: mastodon.v1.Conversation) => conversation.lastStatus ? conversation.lastStatus.account.id === currentUser.value?.account.id : false + return items.filter(item => isAuthored(item) || !item.lastStatus?.filtered?.find( filter => filter.filter.filterAction === 'hide' && filter.filter.context.includes('thread'), )) } diff --git a/components/status/StatusContent.vue b/components/status/StatusContent.vue index 459f4cd7..2bb8997a 100644 --- a/components/status/StatusContent.vue +++ b/components/status/StatusContent.vue @@ -15,7 +15,11 @@ const filterResult = $computed(() => status.filtered?.length ? status.filtered[0 const filter = $computed(() => filterResult?.filter) const filterPhrase = $computed(() => filter?.title) -const isFiltered = $computed(() => filterPhrase && (context && context !== 'details' ? filter?.context.includes(context) : false)) +const isFiltered = $computed(() => status.account.id !== currentUser.value?.account.id && filterPhrase && context && context !== 'details' && !!filter?.context.includes(context)) + +// check spoiler text or media attachment +// needed to handle accounts that mark all their posts as sensitive +const hasSensitiveSpoilerOrMedia = $computed(() => status.sensitive && (!!status.spoilerText || !!status.mediaAttachments.length))