2022-11-26 02:49:56 +03:00
|
|
|
<script setup lang="ts">
|
2022-11-30 20:15:18 +03:00
|
|
|
import type { Account } from 'masto'
|
|
|
|
|
2022-11-26 02:49:56 +03:00
|
|
|
const params = useRoute().params
|
2022-11-30 10:08:10 +03:00
|
|
|
const handle = $(computedEager(() => params.account as string))
|
2022-11-26 02:49:56 +03:00
|
|
|
|
2022-11-30 20:15:18 +03:00
|
|
|
definePageMeta({ name: 'account-index' })
|
|
|
|
|
|
|
|
const { data: account } = await useAsyncData(`account:${handle}`, async () => (
|
|
|
|
window.history.state?.account as Account | undefined)
|
|
|
|
?? await fetchAccountByHandle(handle),
|
|
|
|
)
|
2022-11-29 10:18:28 +03:00
|
|
|
const { t } = useI18n()
|
2022-11-26 02:49:56 +03:00
|
|
|
|
2022-11-30 20:15:18 +03:00
|
|
|
const paginatorPosts = useMasto().accounts.getStatusesIterable(account.value!.id, { excludeReplies: true })
|
|
|
|
const paginatorPostsWithReply = useMasto().accounts.getStatusesIterable(account.value!.id, { excludeReplies: false })
|
|
|
|
const paginatorMedia = useMasto().accounts.getStatusesIterable(account.value!.id, { onlyMedia: true, excludeReplies: false })
|
2022-11-26 02:49:56 +03:00
|
|
|
|
2022-11-29 10:18:28 +03:00
|
|
|
const tabs = $computed(() => [
|
|
|
|
{
|
|
|
|
name: 'posts',
|
|
|
|
display: t('tab.posts'),
|
2022-11-29 11:15:05 +03:00
|
|
|
icon: 'i-ri:file-list-2-line',
|
2022-11-29 10:18:28 +03:00
|
|
|
paginator: paginatorPosts,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'relies',
|
|
|
|
display: t('tab.posts_with_replies'),
|
2022-11-29 11:15:05 +03:00
|
|
|
icon: 'i-ri:chat-3-line',
|
2022-11-29 10:18:28 +03:00
|
|
|
paginator: paginatorPostsWithReply,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'media',
|
|
|
|
display: t('tab.media'),
|
2022-11-29 11:15:05 +03:00
|
|
|
icon: 'i-ri:camera-2-line',
|
2022-11-29 10:18:28 +03:00
|
|
|
paginator: paginatorMedia,
|
|
|
|
},
|
|
|
|
] as const)
|
2022-11-26 20:36:23 +03:00
|
|
|
|
2022-11-29 10:18:28 +03:00
|
|
|
// Don't use local storage because it is better to default to Posts every time you visit a user's profile.
|
|
|
|
const tab = $ref(tabs[0].name)
|
|
|
|
const paginator = $computed(() => tabs.find(t => t.name === tab)!.paginator)
|
2022-11-26 02:49:56 +03:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2022-12-01 17:09:11 +03:00
|
|
|
<div v-if="account!.discoverable">
|
2022-11-29 11:15:05 +03:00
|
|
|
<CommonTabs v-model="tab" :options="tabs" command />
|
2022-11-26 02:49:56 +03:00
|
|
|
<KeepAlive>
|
|
|
|
<TimelinePaginator :key="tab" :paginator="paginator" />
|
|
|
|
</KeepAlive>
|
|
|
|
</div>
|
2022-12-01 17:12:31 +03:00
|
|
|
<div v-else h-30 flex="~ center" text-secondary-light>
|
2022-12-01 17:09:11 +03:00
|
|
|
Profile unavailable
|
|
|
|
</div>
|
2022-11-26 02:49:56 +03:00
|
|
|
</template>
|