feat: use nested routes for profile

This commit is contained in:
Anthony Fu 2022-11-24 14:18:05 +08:00
parent e81273e944
commit 1ee945447d
12 changed files with 56 additions and 36 deletions

View file

@ -12,21 +12,19 @@ const tabNames = ['Posts', 'Posts and replies'] as const
// 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 paginator1 = masto.accounts.getStatusesIterable(account.id, { excludeReplies: true })
const paginator2 = masto.accounts.getStatusesIterable(account.id, { excludeReplies: false })
const paginator = $computed(() => {
return masto.accounts.getStatusesIterable(account.id, { excludeReplies: tab === 'Posts' } as any)
return tab === 'Posts' ? paginator1 : paginator2
})
</script>
<template>
<template v-if="account">
<div>
<AccountHeader :account="account" />
</div>
<div>
<CommonTabs v-model="tab" :options="tabNames" />
<TimelinePaginator :key="tab" :paginator="paginator" />
</template>
<CommonNotFound v-else>
Account @{{ params.user }} not found
</CommonNotFound>
<KeepAlive>
<TimelinePaginator :key="tab" :paginator="paginator" />
</KeepAlive>
</div>
</template>