feat: status route using full account (#115)

This commit is contained in:
patak 2022-11-26 00:49:56 +01:00 committed by GitHub
parent b36a803eef
commit 4bb2910761
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 104 additions and 81 deletions

View file

@ -1,26 +1,25 @@
<script setup lang="ts">
const params = useRoute().params
const accountName = $computed(() => params.account as string)
const accountName = $computed(() => toShortHandle(params.account as string))
const account = await fetchAccountByName(accountName)
const tabNames = ['Posts', 'Posts and replies'] as const
const account = await fetchAccountByName(accountName).catch(() => null)
// Don't use local storage because it is better to default to Posts every time you visit a user's profile.
const tab = $ref('Posts')
const paginatorPosts = masto.accounts.getStatusesIterable(account.id, { excludeReplies: true })
const paginatorPostsWithReply = masto.accounts.getStatusesIterable(account.id, { excludeReplies: false })
const paginator = $computed(() => {
return tab === 'Posts' ? paginatorPosts : paginatorPostsWithReply
})
if (account) {
useHead({
title: () => `${account.displayName?.replace(/\:\w+\:/g, '') ?? ''} (@${account.acct})`,
})
}
</script>
<template>
<div>
<CommonTabs v-model="tab" :options="tabNames" />
<KeepAlive>
<TimelinePaginator :key="tab" :paginator="paginator" />
</KeepAlive>
</div>
<MainContent>
<template v-if="account">
<AccountHeader :account="account" border="b base" />
<NuxtPage />
</template>
<CommonNotFound v-else>
Account @{{ accountName }} not found
</CommonNotFound>
</MainContent>
</template>