2022-11-25 23:49:56 +00:00
|
|
|
<script setup lang="ts">
|
2023-01-16 00:33:07 +00:00
|
|
|
// @ts-expect-error missing types
|
|
|
|
import { DynamicScroller, DynamicScrollerItem } from 'vue-virtual-scroller'
|
2022-11-27 00:35:19 +00:00
|
|
|
import type { ComponentPublicInstance } from 'vue'
|
2022-11-25 23:49:56 +00:00
|
|
|
|
2022-11-30 17:15:18 +00:00
|
|
|
definePageMeta({
|
|
|
|
name: 'status',
|
2022-12-11 23:30:26 +00:00
|
|
|
key: route => route.path,
|
2023-01-15 09:55:58 +00:00
|
|
|
// GoToSocial
|
2023-01-15 19:09:01 +00:00
|
|
|
alias: ['/:server?/@:account/statuses/:status'],
|
2022-11-30 17:15:18 +00:00
|
|
|
})
|
|
|
|
|
2022-11-25 23:49:56 +00:00
|
|
|
const route = useRoute()
|
2024-02-24 12:24:21 +00:00
|
|
|
const id = computed(() => route.params.status as string)
|
2022-11-27 00:35:19 +00:00
|
|
|
const main = ref<ComponentPublicInstance | null>(null)
|
2022-12-30 16:38:46 +00:00
|
|
|
|
2022-12-26 14:14:48 +00:00
|
|
|
const { data: status, pending, refresh: refreshStatus } = useAsyncData(
|
2024-02-21 15:20:08 +00:00
|
|
|
`status:${id.value}`,
|
|
|
|
() => fetchStatus(id.value, true),
|
2023-01-16 00:33:07 +00:00
|
|
|
{ watch: [isHydrated], immediate: isHydrated.value, default: () => shallowRef() },
|
2022-11-28 10:23:33 +00:00
|
|
|
)
|
2024-02-21 15:20:08 +00:00
|
|
|
const { client } = useMasto()
|
2023-01-04 19:55:57 +00:00
|
|
|
const { data: context, pending: pendingContext, refresh: refreshContext } = useAsyncData(
|
2024-03-11 10:53:25 +00:00
|
|
|
`context:${id.value}`,
|
2024-02-21 15:20:08 +00:00
|
|
|
async () => client.value.v1.statuses.$select(id.value).context.fetch(),
|
2023-01-16 00:33:07 +00:00
|
|
|
{ watch: [isHydrated], immediate: isHydrated.value, lazy: true, default: () => shallowRef() },
|
2023-01-04 19:55:57 +00:00
|
|
|
)
|
2022-11-27 00:35:19 +00:00
|
|
|
|
2023-02-17 22:11:35 +00:00
|
|
|
if (pendingContext)
|
|
|
|
watchOnce(pendingContext, scrollTo)
|
|
|
|
|
|
|
|
if (pending)
|
|
|
|
watchOnce(pending, scrollTo)
|
|
|
|
|
|
|
|
async function scrollTo() {
|
|
|
|
await nextTick()
|
2022-11-28 10:23:33 +00:00
|
|
|
|
2022-11-27 00:35:19 +00:00
|
|
|
const statusElement = unrefElement(main)
|
|
|
|
if (!statusElement)
|
|
|
|
return
|
|
|
|
|
|
|
|
statusElement.scrollIntoView(true)
|
|
|
|
}
|
|
|
|
|
2023-02-17 22:11:35 +00:00
|
|
|
const publishWidget = ref()
|
2023-03-30 19:01:24 +00:00
|
|
|
function focusEditor() {
|
|
|
|
return publishWidget.value?.focusEditor?.()
|
|
|
|
}
|
2022-12-14 16:45:46 +00:00
|
|
|
|
|
|
|
provide('focus-editor', focusEditor)
|
|
|
|
|
2023-01-07 07:55:07 +00:00
|
|
|
watch(publishWidget, () => {
|
|
|
|
if (window.history.state.focusReply)
|
|
|
|
focusEditor()
|
|
|
|
})
|
|
|
|
|
2024-02-21 15:20:08 +00:00
|
|
|
const replyDraft = computed(() => status.value ? getReplyDraft(status.value) : null)
|
2023-02-17 22:11:35 +00:00
|
|
|
|
2022-11-27 17:34:45 +00:00
|
|
|
onReactivated(() => {
|
|
|
|
// Silently update data when reentering the page
|
|
|
|
// The user will see the previous content first, and any changes will be updated to the UI when the request is completed
|
|
|
|
refreshStatus()
|
|
|
|
refreshContext()
|
|
|
|
})
|
2022-11-25 23:49:56 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2022-11-26 12:58:10 +00:00
|
|
|
<MainContent back>
|
2023-02-17 22:11:35 +00:00
|
|
|
<template v-if="!pending">
|
|
|
|
<template v-if="status">
|
|
|
|
<div xl:mt-4 mb="50vh" border="b base">
|
|
|
|
<template v-if="!pendingContext">
|
2023-01-16 00:33:07 +00:00
|
|
|
<StatusCard
|
2024-02-24 12:24:21 +00:00
|
|
|
v-for="(comment, i) of context?.ancestors" :key="comment.id"
|
2023-02-17 22:11:35 +00:00
|
|
|
:status="comment" :actions="comment.visibility !== 'direct'" context="account"
|
|
|
|
:has-older="true" :newer="context?.ancestors[i - 1]"
|
2023-01-16 00:33:07 +00:00
|
|
|
/>
|
2023-02-17 22:11:35 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<StatusDetails
|
|
|
|
ref="main"
|
|
|
|
:status="status"
|
|
|
|
:newer="context?.ancestors.at(-1)"
|
|
|
|
command
|
|
|
|
style="scroll-margin-top: 60px"
|
2023-04-30 15:19:14 +00:00
|
|
|
@refetch-status="refreshStatus()"
|
2023-02-17 22:11:35 +00:00
|
|
|
/>
|
|
|
|
<PublishWidget
|
|
|
|
v-if="currentUser"
|
|
|
|
ref="publishWidget"
|
|
|
|
border="y base"
|
|
|
|
:draft-key="replyDraft!.key"
|
|
|
|
:initial="replyDraft!.draft"
|
|
|
|
@published="refreshContext()"
|
|
|
|
/>
|
|
|
|
|
|
|
|
<template v-if="!pendingContext">
|
|
|
|
<DynamicScroller
|
|
|
|
v-slot="{ item, index, active }"
|
|
|
|
:items="context?.descendants || []"
|
|
|
|
:min-item-size="200"
|
2023-03-06 18:58:22 +00:00
|
|
|
:buffer="800"
|
2023-02-17 22:11:35 +00:00
|
|
|
key-field="id"
|
|
|
|
page-mode
|
|
|
|
>
|
|
|
|
<DynamicScrollerItem :item="item" :active="active">
|
|
|
|
<StatusCard
|
2023-07-03 19:04:16 +00:00
|
|
|
:key="item.id"
|
2023-02-17 22:11:35 +00:00
|
|
|
:status="item"
|
|
|
|
context="account"
|
|
|
|
:older="context?.descendants[index + 1]"
|
|
|
|
:newer="index > 0 ? context?.descendants[index - 1] : status"
|
|
|
|
:has-newer="index === 0"
|
|
|
|
:main="status"
|
|
|
|
/>
|
|
|
|
</DynamicScrollerItem>
|
|
|
|
</DynamicScroller>
|
|
|
|
</template>
|
|
|
|
</div>
|
|
|
|
</template>
|
2022-11-25 23:49:56 +00:00
|
|
|
|
2023-01-05 16:48:20 +00:00
|
|
|
<StatusNotFound v-else :account="route.params.account as string" :status="id" />
|
2022-11-28 11:09:38 +00:00
|
|
|
</template>
|
|
|
|
|
2022-12-06 11:07:17 +00:00
|
|
|
<StatusCardSkeleton v-else border="b base" />
|
2023-02-17 22:11:35 +00:00
|
|
|
<TimelineSkeleton v-if="pending || pendingContext" />
|
2022-11-25 23:49:56 +00:00
|
|
|
</MainContent>
|
|
|
|
</template>
|