1
0
mirror of https://github.com/elk-zone/elk synced 2024-12-04 01:38:06 +09:00
elk/components/status/StatusContent.vue

57 lines
2.0 KiB
Vue
Raw Normal View History

2022-12-26 16:37:42 +09:00
<script setup lang="ts">
2023-01-08 15:21:09 +09:00
import type { mastodon } from 'masto'
2022-12-26 16:37:42 +09:00
const { status, context } = defineProps<{
2023-01-08 15:21:09 +09:00
status: mastodon.v1.Status
context?: mastodon.v2.FilterContext | 'details'
2022-12-26 16:37:42 +09:00
}>()
const isDM = $computed(() => status.visibility === 'direct')
const isDetails = $computed(() => context === 'details')
// Content Filter logic
const filterResult = $computed(() => status.filtered?.length ? status.filtered[0] : null)
const filter = $computed(() => filterResult?.filter)
2023-01-10 15:10:20 +09:00
const filterPhrase = $computed(() => filter?.title)
2022-12-26 16:37:42 +09:00
const isFiltered = $computed(() => filterPhrase && (context && context !== 'details' ? filter?.context.includes(context) : false))
</script>
<template>
<div
space-y-3
:class="{
2023-01-10 14:58:07 +09:00
'pt2 pb0.5 px3.5 bg-dm rounded-4 me--1': isDM,
2023-01-04 01:25:43 +09:00
'ms--3.5 mt--1 ms--1': isDM && context !== 'details',
2022-12-26 16:37:42 +09:00
}"
>
<StatusBody v-if="!isFiltered && status.sensitive && !status.spoilerText" :status="status" :with-action="!isDetails" :class="isDetails ? 'text-xl' : ''" />
2022-12-26 16:37:42 +09:00
<StatusSpoiler :enabled="status.sensitive || isFiltered" :filter="isFiltered">
<template v-if="filterPhrase" #spoiler>
<p>{{ `${$t('status.filter_hidden_phrase')}: ${filterPhrase}` }}</p>
2022-12-26 16:37:42 +09:00
</template>
<template v-else-if="status.spoilerText" #spoiler>
<p>{{ status.spoilerText }}</p>
</template>
<StatusBody v-if="!status.sensitive || status.spoilerText" :status="status" :with-action="!isDetails" :class="isDetails ? 'text-xl' : ''" />
<StatusTranslation :status="status" />
<StatusPoll v-if="status.poll" :status="status" />
2022-12-26 16:37:42 +09:00
<StatusMedia
v-if="status.mediaAttachments?.length"
:status="status"
/>
<StatusPreviewCard
v-if="status.card"
:card="status.card"
:small-picture-only="status.mediaAttachments?.length > 0"
/>
<StatusCard
v-if="status.reblog"
:status="status.reblog" border="~ rounded"
:actions="false"
/>
<div v-if="isDM" />
</StatusSpoiler>
</div>
</template>