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 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,17 +39,23 @@ 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
<span italic>{{ $t('timeline.view_older_posts') }}</span> v-if="showOriginSite || items.length === 0"
<NuxtLink p5 text-secondary text-center flex flex-col items-center gap1
:href="account!.url" target="_blank" external >
flex="~ gap-1" items-center text-primary <template v-if="showOriginSite">
hover="underline text-primary-active" <span italic>{{ $t('timeline.view_older_posts') }}</span>
> <NuxtLink
<div i-ri:external-link-fill /> :href="account!.url" target="_blank" external
{{ $t('menu.open_in_original_site') }} flex="~ gap-1" items-center text-primary
</NuxtLink> hover="underline text-primary-active"
>
<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> </div>
</template> </template>
</CommonPaginator> </CommonPaginator>