feat: show hint on empty timeline

zio/stable
三咲智子 Kevin Deng 2023-07-05 14:33:41 +08:00
parent 5c1411b3de
commit 1ee0ec68c5
No known key found for this signature in database
GPG Key ID: 69992F2250DFD93E
2 changed files with 20 additions and 14 deletions

View File

@ -40,7 +40,7 @@ defineSlots<{
update: () => void
}) => void
loading: (props: {}) => void
done: (props: {}) => void
done: (props: { items: U[] }) => void
}>()
const { t } = useI18n()
@ -110,7 +110,7 @@ defineExpose({ createEntry, removeEntry, updateEntry })
<slot v-if="state === 'loading'" name="loading">
<TimelineSkeleton />
</slot>
<slot v-else-if="state === 'done' && endMessage !== false" name="done">
<slot v-else-if="state === 'done' && endMessage !== false" name="done" :items="items as U[]">
<div p5 text-secondary italic text-center>
{{ t(typeof endMessage === 'string' ? endMessage : 'common.end_of_list') }}
</div>

View File

@ -4,7 +4,7 @@ import { DynamicScrollerItem } from 'vue-virtual-scroller'
import 'vue-virtual-scroller/dist/vue-virtual-scroller.css'
import type { Paginator, WsEvents, mastodon } from 'masto'
const { paginator, stream, account, buffer = 10, endMessage } = defineProps<{
const { paginator, stream, account, buffer = 10, endMessage = true } = defineProps<{
paginator: Paginator<mastodon.v1.Status[], mastodon.v1.ListAccountStatusesParams>
stream?: Promise<WsEvents>
context?: mastodon.v2.FilterContext
@ -39,8 +39,12 @@ const showOriginSite = $computed(() =>
<StatusCard :status="item" :context="context" :older="older" :newer="newer" />
</template>
</template>
<template v-if="context === 'account' && showOriginSite" #done>
<div p5 text-secondary text-center flex flex-col items-center gap1>
<template v-if="context === 'account' " #done="{ items }">
<div
v-if="showOriginSite || items.length === 0"
p5 text-secondary text-center flex flex-col items-center gap1
>
<template v-if="showOriginSite">
<span italic>{{ $t('timeline.view_older_posts') }}</span>
<NuxtLink
:href="account!.url" target="_blank" external
@ -50,6 +54,8 @@ const showOriginSite = $computed(() =>
<div i-ri:external-link-fill />
{{ $t('menu.open_in_original_site') }}
</NuxtLink>
</template>
<span v-else-if="items.length === 0">No posts here!</span>
</div>
</template>
</CommonPaginator>