From 075a9d115b3497a13d6ca8453045d0c267b0958e Mon Sep 17 00:00:00 2001 From: Ayo Date: Sun, 29 Jan 2023 00:39:03 +0100 Subject: [PATCH] feat: clean shared link in the parsed html if conditions are met --- components/status/StatusBody.vue | 16 +++++++++++++++ components/status/StatusContent.vue | 7 ++++++- components/status/StatusPreviewCard.vue | 5 +++-- components/status/StatusPreviewCardNormal.vue | 4 +++- composables/content-parse.ts | 20 ++++++++++++++++++- 5 files changed, 47 insertions(+), 5 deletions(-) diff --git a/components/status/StatusBody.vue b/components/status/StatusBody.vue index 733f9974..8a41e050 100644 --- a/components/status/StatusBody.vue +++ b/components/status/StatusBody.vue @@ -5,15 +5,29 @@ const { status, newer, withAction = true, + cleanSharedLink, } = defineProps<{ status: mastodon.v1.Status | mastodon.v1.StatusEdit newer?: mastodon.v1.Status withAction?: boolean + cleanSharedLink?: string | false }>() const { translation } = useTranslation(status, getLanguageCode()) const emojisObject = useEmojisFallback(() => status.emojis) + +/** + * example status raw content + * + *

🔴 trying to code live - come let's talk @elk and twitch.tv/ayoayco

+ * + * + * "

I say something about the link first

https://ayco.io

" + + * + */ + const vnode = $computed(() => { if (!status.content) return null @@ -24,7 +38,9 @@ const vnode = $computed(() => { collapseMentionLink: !!('inReplyToId' in status && status.inReplyToId), status: 'id' in status ? status : undefined, inReplyToStatus: newer, + cleanSharedLink, }) + return vnode }) diff --git a/components/status/StatusContent.vue b/components/status/StatusContent.vue index 459f4cd7..01a84355 100644 --- a/components/status/StatusContent.vue +++ b/components/status/StatusContent.vue @@ -16,6 +16,10 @@ const filter = $computed(() => filterResult?.filter) const filterPhrase = $computed(() => filter?.title) const isFiltered = $computed(() => filterPhrase && (context && context !== 'details' ? filter?.context.includes(context) : false)) + +const cleanSharedLink = !status.poll + && !status.mediaAttachments.length + && status.card?.url