fix: rework tip for unavailable posts

refactor #767
This commit is contained in:
三咲智子 2023-01-07 02:29:44 +08:00
parent a311e0ec80
commit 79e4841f87
No known key found for this signature in database
GPG key ID: 69992F2250DFD93E
5 changed files with 29 additions and 26 deletions

View file

@ -11,7 +11,6 @@ const {
virtualScroller = false,
eventType = 'update',
preprocess,
isAccountTimeline,
} = defineProps<{
paginator: Paginator<any, any[]>
keyProp?: string
@ -19,7 +18,6 @@ const {
stream?: Promise<WsEvents>
eventType?: 'notification' | 'update'
preprocess?: (items: any[]) => any[]
isAccountTimeline?: boolean
}>()
defineSlots<{
@ -34,18 +32,9 @@ defineSlots<{
update: () => void
}
loading: {}
done: {}
}>()
let account: Account | null = null
const { params } = useRoute()
if (isAccountTimeline) {
const handle = $(computedEager(() => params.account as string))
account = await fetchAccountByHandle(handle)
}
const { items, prevItems, update, state, endAnchor, error } = usePaginator(paginator, stream, eventType, preprocess)
</script>
@ -84,15 +73,11 @@ const { items, prevItems, update, state, endAnchor, error } = usePaginator(pagin
<slot v-if="state === 'loading'" name="loading">
<TimelineSkeleton />
</slot>
<div v-else-if="state === 'done'" p5 text-secondary italic text-center flex flex-col items-center gap1>
<template v-if="isAccountTimeline">
<span>{{ $t('timeline.view_older_posts') }}</span>
<a :href="account!.url" not-italic text-primary hover="underline text-primary-active">{{ $t('menu.open_in_original_site') }}</a>
</template>
<template v-else>
<slot v-else-if="state === 'done'" name="done">
<div p5 text-secondary italic text-center>
{{ $t('common.end_of_list') }}
</template>
</div>
</div>
</slot>
<div v-else-if="state === 'error'" p5 text-secondary>
{{ $t('common.error') }}: {{ error }}
</div>