feat: Add profile viewer

This commit is contained in:
Jesse Wierzbinski 2024-12-02 16:07:52 +01:00
parent a6c5093cf5
commit 1194bc4ffb
No known key found for this signature in database
19 changed files with 466 additions and 47 deletions

View file

@ -1,8 +1,8 @@
<template>
<ErrorBoundary>
<div class="mx-auto max-w-2xl w-full">
<TimelineScroller>
<AccountProfile :account="account ?? undefined" />
<div class="mx-auto max-w-2xl w-full space-y-2">
<TimelineScroller v-if="account">
<AccountProfile :account="account" />
<AccountTimeline v-if="accountId" :id="accountId" :key="accountId" />
</TimelineScroller>
</div>
@ -10,9 +10,8 @@
</template>
<script setup lang="ts">
import type { Account } from "@versia/client/types";
import ErrorBoundary from "~/components/errors/ErrorBoundary.vue";
import AccountProfile from "~/components/social-elements/users/Account.vue";
import AccountProfile from "~/components/profiles/profile.vue";
import AccountTimeline from "~/components/timelines/account.vue";
import TimelineScroller from "~/components/timelines/timeline-scroller.vue";
@ -25,29 +24,7 @@ const username = (route.params.username as string).startsWith("@")
? (route.params.username as string).substring(1)
: (route.params.username as string);
const accounts = useAccountSearch(client, username);
watch(accounts, (newValue) => {
if (Array.isArray(newValue)) {
if (
!newValue.find(
(account) =>
account.acct.toLowerCase() === username.toLowerCase(),
)
) {
useEvent("error", {
title: "Account not found",
message: `The account <code>@${username}</code> does not exist.`,
code: "ERR_ACCOUNT_NOT_FOUND",
});
}
}
});
const account = computed<Account | null>(
() =>
accounts.value?.find(
(account) => account.acct.toLowerCase() === username.toLowerCase(),
) ?? null,
);
const account = useAccountFromAcct(client, username);
const accountId = computed(() => account.value?.id ?? undefined);
useServerSeoMeta({