2022-11-23 00:00:52 +00:00
|
|
|
<script setup lang="ts">
|
2023-01-08 06:21:09 +00:00
|
|
|
import type { mastodon } from 'masto'
|
2024-03-04 19:55:02 +00:00
|
|
|
import { fetchAccountById } from '~/composables/cache'
|
2022-11-23 00:00:52 +00:00
|
|
|
|
2024-03-04 19:55:02 +00:00
|
|
|
type WatcherType = [status?: mastodon.v1.Status, v?: boolean]
|
|
|
|
|
|
|
|
const props = defineProps<{
|
2023-01-08 06:21:09 +00:00
|
|
|
status: mastodon.v1.Status
|
2023-01-08 08:27:21 +00:00
|
|
|
isSelfReply: boolean
|
2022-11-23 00:00:52 +00:00
|
|
|
}>()
|
|
|
|
|
2024-03-04 19:55:02 +00:00
|
|
|
const link = ref()
|
|
|
|
const targetIsVisible = ref(false)
|
|
|
|
const isSelf = computed(() => props.status.inReplyToAccountId === props.status.account.id)
|
|
|
|
const account = ref<mastodon.v1.Account | null | undefined>(isSelf.value ? props.status.account : undefined)
|
|
|
|
|
|
|
|
useIntersectionObserver(
|
|
|
|
link,
|
|
|
|
([{ intersectionRatio }]) => {
|
|
|
|
targetIsVisible.value = intersectionRatio > 0.1
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
watch(
|
|
|
|
() => [props.status, targetIsVisible.value] satisfies WatcherType,
|
|
|
|
([newStatus, newVisible]) => {
|
|
|
|
if (newStatus.account) {
|
|
|
|
account.value = newStatus.account
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!newVisible)
|
|
|
|
return
|
|
|
|
|
|
|
|
const newId = newStatus.inReplyToAccountId
|
|
|
|
|
|
|
|
if (newId) {
|
|
|
|
fetchAccountById(newStatus.inReplyToAccountId).then((acc) => {
|
|
|
|
if (newId === props.status.inReplyToAccountId)
|
|
|
|
account.value = acc
|
|
|
|
})
|
|
|
|
return
|
|
|
|
}
|
|
|
|
account.value = undefined
|
|
|
|
}, { immediate: true, flush: 'post' },
|
|
|
|
)
|
2022-11-23 00:00:52 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2023-01-08 08:27:21 +00:00
|
|
|
<NuxtLink
|
|
|
|
v-if="status.inReplyToId"
|
2024-03-04 19:55:02 +00:00
|
|
|
ref="link"
|
2023-01-08 08:27:21 +00:00
|
|
|
flex="~ gap2" items-center h-auto text-sm text-secondary
|
|
|
|
:to="getStatusInReplyToRoute(status)"
|
2023-01-08 09:03:23 +00:00
|
|
|
:title="$t('status.replying_to', [account ? getDisplayName(account) : $t('status.someone')])"
|
|
|
|
text-blue saturate-50 hover:saturate-100
|
2023-01-08 08:27:21 +00:00
|
|
|
>
|
|
|
|
<template v-if="isSelfReply">
|
2023-01-08 09:03:23 +00:00
|
|
|
<div i-ri-discuss-line text-blue />
|
|
|
|
<span>{{ $t('status.show_full_thread') }}</span>
|
2023-01-08 08:27:21 +00:00
|
|
|
</template>
|
|
|
|
<template v-else>
|
2023-01-08 09:03:23 +00:00
|
|
|
<div i-ri-chat-1-line text-blue />
|
2023-02-15 19:21:08 +00:00
|
|
|
<div ws-nowrap flex>
|
|
|
|
<i18n-t keypath="status.replying_to">
|
|
|
|
<template v-if="account">
|
2023-03-19 22:36:09 +00:00
|
|
|
<AccountInlineInfo :account="account" :link="false" m-inline-2 />
|
2023-02-15 19:21:08 +00:00
|
|
|
</template>
|
|
|
|
<template v-else>
|
|
|
|
{{ $t('status.someone') }}
|
|
|
|
</template>
|
|
|
|
</i18n-t>
|
2023-02-07 08:12:30 +00:00
|
|
|
</div>
|
2023-01-08 08:27:21 +00:00
|
|
|
</template>
|
|
|
|
</NuxtLink>
|
2022-11-23 00:00:52 +00:00
|
|
|
</template>
|