2022-11-25 23:49:56 +00:00
|
|
|
<script setup lang="ts">
|
2022-11-27 00:35:19 +00:00
|
|
|
import type { ComponentPublicInstance } from 'vue'
|
2022-11-25 23:49:56 +00:00
|
|
|
|
|
|
|
const route = useRoute()
|
|
|
|
const id = $computed(() => route.params.status as string)
|
2022-11-27 00:35:19 +00:00
|
|
|
const main = ref<ComponentPublicInstance | null>(null)
|
|
|
|
let bottomSpace = $ref(0)
|
2022-11-25 23:49:56 +00:00
|
|
|
|
|
|
|
const status = window.history.state?.status ?? await fetchStatus(id)
|
2022-11-27 00:35:19 +00:00
|
|
|
const { data: context, pending } = useAsyncData(`context:${id}`, () => useMasto().statuses.fetchContext(id))
|
|
|
|
|
|
|
|
function scrollTo() {
|
|
|
|
const statusElement = unrefElement(main)
|
|
|
|
if (!statusElement)
|
|
|
|
return
|
|
|
|
|
|
|
|
const statusRect = statusElement.getBoundingClientRect()
|
|
|
|
bottomSpace = window.innerHeight - statusRect.height
|
|
|
|
statusElement.scrollIntoView(true)
|
|
|
|
}
|
|
|
|
|
|
|
|
onMounted(scrollTo)
|
|
|
|
|
|
|
|
if (pending) {
|
|
|
|
watchOnce(pending, async () => {
|
|
|
|
await nextTick()
|
|
|
|
scrollTo()
|
|
|
|
})
|
|
|
|
}
|
2022-11-25 23:49:56 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2022-11-26 12:58:10 +00:00
|
|
|
<MainContent back>
|
2022-11-27 00:35:19 +00:00
|
|
|
<div v-if="status" min-h-100vh>
|
2022-11-25 23:49:56 +00:00
|
|
|
<template v-if="context">
|
|
|
|
<template v-for="comment of context?.ancestors" :key="comment.id">
|
|
|
|
<StatusCard :status="comment" border="t base" py3 />
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
|
2022-11-27 00:35:19 +00:00
|
|
|
<StatusDetails
|
|
|
|
ref="main"
|
|
|
|
:status="status"
|
|
|
|
border="t base"
|
|
|
|
style="scroll-margin-top: 60px"
|
|
|
|
/>
|
2022-11-25 23:49:56 +00:00
|
|
|
<PublishWidget
|
|
|
|
v-if="currentUser"
|
|
|
|
border="t base"
|
|
|
|
:draft-key="`reply-${id}`"
|
2022-11-26 15:06:30 +00:00
|
|
|
:placeholder="`Reply to ${status?.account ? getDisplayName(status.account) : 'this thread'}`"
|
2022-11-25 23:49:56 +00:00
|
|
|
:in-reply-to-id="id"
|
|
|
|
/>
|
|
|
|
|
|
|
|
<template v-if="context">
|
|
|
|
<template v-for="comment of context?.descendants" :key="comment.id">
|
|
|
|
<StatusCard :status="comment" border="t base" py3 />
|
|
|
|
</template>
|
|
|
|
</template>
|
2022-11-27 00:35:19 +00:00
|
|
|
|
|
|
|
<div border="t base" :style="{ height: `${bottomSpace}px` }" />
|
|
|
|
</div>
|
2022-11-25 23:49:56 +00:00
|
|
|
|
|
|
|
<CommonNotFound v-else>
|
|
|
|
Status not found
|
|
|
|
</CommonNotFound>
|
|
|
|
</MainContent>
|
|
|
|
</template>
|