feat: open reply dialog on timeline

closes #125
This commit is contained in:
三咲智子 2022-11-28 18:23:33 +08:00
parent c2f3526e88
commit 9fca8eee30
No known key found for this signature in database
GPG key ID: 69992F2250DFD93E
6 changed files with 85 additions and 53 deletions

View file

@ -1,4 +1,5 @@
<script setup lang="ts">
import type { Status } from 'masto'
import type { ComponentPublicInstance } from 'vue'
const route = useRoute()
@ -6,9 +7,14 @@ const id = $(computedEager(() => route.params.status as string))
const main = ref<ComponentPublicInstance | null>(null)
let bottomSpace = $ref(0)
const { data: status, refresh: refreshStatus } = useAsyncData(async () => window.history.state?.status ?? await fetchStatus(id))
const { data: status, refresh: refreshStatus } = useAsyncData(async () => (
window.history.state?.status as Status | undefined)
?? await fetchStatus(id),
)
const { data: context, pending, refresh: refreshContext } = useAsyncData(`context:${id}`, () => useMasto().statuses.fetchContext(id))
const replyDraft = $computed(() => status.value ? getReplyDraft(status.value) : null)
function scrollTo() {
const statusElement = unrefElement(main)
if (!statusElement)
@ -53,11 +59,9 @@ onReactivated(() => {
/>
<PublishWidget
v-if="currentUser"
:draft-key="replyDraft!.key"
:initial="replyDraft!.draft"
border="t base"
:draft-key="`reply-${id}`"
:placeholder="`Reply to ${status?.account ? getDisplayName(status.account) : 'this thread'}`"
:in-reply-to-id="id"
:in-reply-to-visibility="status.visibility"
/>
<template v-if="context">