feat: show hint on empty timeline

This commit is contained in:
三咲智子 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 update: () => void
}) => void }) => void
loading: (props: {}) => void loading: (props: {}) => void
done: (props: {}) => void done: (props: { items: U[] }) => void
}>() }>()
const { t } = useI18n() const { t } = useI18n()
@ -110,7 +110,7 @@ defineExpose({ createEntry, removeEntry, updateEntry })
<slot v-if="state === 'loading'" name="loading"> <slot v-if="state === 'loading'" name="loading">
<TimelineSkeleton /> <TimelineSkeleton />
</slot> </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> <div p5 text-secondary italic text-center>
{{ t(typeof endMessage === 'string' ? endMessage : 'common.end_of_list') }} {{ t(typeof endMessage === 'string' ? endMessage : 'common.end_of_list') }}
</div> </div>

View file

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