mirror of
https://github.com/elk-zone/elk
synced 2024-11-27 22:38:11 +09:00
fix: show skeleton when loading status
This commit is contained in:
parent
eafcb5111a
commit
d94bed686b
@ -7,11 +7,11 @@ 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 () => (
|
||||
const { data: status, pending, 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 { data: context, pending: pendingContext, refresh: refreshContext } = useAsyncData(`context:${id}`, () => useMasto().statuses.fetchContext(id))
|
||||
|
||||
const replyDraft = $computed(() => status.value ? getReplyDraft(status.value) : null)
|
||||
|
||||
@ -27,8 +27,8 @@ function scrollTo() {
|
||||
|
||||
onMounted(scrollTo)
|
||||
|
||||
if (pending) {
|
||||
watchOnce(pending, async () => {
|
||||
if (pendingContext) {
|
||||
watchOnce(pendingContext, async () => {
|
||||
await nextTick()
|
||||
scrollTo()
|
||||
})
|
||||
@ -44,37 +44,41 @@ onReactivated(() => {
|
||||
|
||||
<template>
|
||||
<MainContent back>
|
||||
<div v-if="status" min-h-100vh>
|
||||
<template v-if="context">
|
||||
<template v-for="comment of context?.ancestors" :key="comment.id">
|
||||
<StatusCard :status="comment" border="t base" py3 />
|
||||
<template v-if="!pending">
|
||||
<div v-if="status" min-h-100vh>
|
||||
<template v-if="context">
|
||||
<template v-for="comment of context?.ancestors" :key="comment.id">
|
||||
<StatusCard :status="comment" border="t base" py3 />
|
||||
</template>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
<StatusDetails
|
||||
ref="main"
|
||||
:status="status"
|
||||
border="t base"
|
||||
style="scroll-margin-top: 60px"
|
||||
/>
|
||||
<PublishWidget
|
||||
v-if="currentUser"
|
||||
:draft-key="replyDraft!.key"
|
||||
:initial="replyDraft!.draft"
|
||||
border="t base"
|
||||
/>
|
||||
<StatusDetails
|
||||
ref="main"
|
||||
:status="status"
|
||||
border="t base"
|
||||
style="scroll-margin-top: 60px"
|
||||
/>
|
||||
<PublishWidget
|
||||
v-if="currentUser"
|
||||
:draft-key="replyDraft!.key"
|
||||
:initial="replyDraft!.draft"
|
||||
border="t base"
|
||||
/>
|
||||
|
||||
<template v-if="context">
|
||||
<template v-for="comment of context?.descendants" :key="comment.id">
|
||||
<StatusCard :status="comment" border="t base" py3 />
|
||||
<template v-if="context">
|
||||
<template v-for="comment of context?.descendants" :key="comment.id">
|
||||
<StatusCard :status="comment" border="t base" py3 />
|
||||
</template>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
<div border="t base" :style="{ height: `${bottomSpace}px` }" />
|
||||
</div>
|
||||
<div border="t base" :style="{ height: `${bottomSpace}px` }" />
|
||||
</div>
|
||||
|
||||
<CommonNotFound v-else>
|
||||
Status not found
|
||||
</CommonNotFound>
|
||||
<CommonNotFound v-else>
|
||||
Status not found
|
||||
</CommonNotFound>
|
||||
</template>
|
||||
|
||||
<StatusCardSkeleton v-else border="b base" py-3 />
|
||||
</MainContent>
|
||||
</template>
|
||||
|
Loading…
Reference in New Issue
Block a user