feat: Add error page when an account is not found

This commit is contained in:
Jesse Wierzbinski 2024-06-11 18:41:27 -10:00
parent 46193938fe
commit 3db36ae618
No known key found for this signature in database
4 changed files with 92 additions and 8 deletions

View file

@ -1,10 +1,12 @@
<template>
<div class="mx-auto max-w-2xl w-full">
<LazyTimelinesTimelineScroller>
<LazySocialElementsUsersAccount :account="account ?? undefined" />
<LazyTimelinesAccount :id="accountId" :key="accountId" />
</LazyTimelinesTimelineScroller>
</div>
<ErrorsErrorBoundary>
<div class="mx-auto max-w-2xl w-full">
<LazyTimelinesTimelineScroller>
<LazySocialElementsUsersAccount :account="account ?? undefined" />
<LazyTimelinesAccount :id="accountId" :key="accountId" />
</LazyTimelinesTimelineScroller>
</div>
</ErrorsErrorBoundary>
</template>
<script setup lang="ts">
@ -19,6 +21,17 @@ const client = useClient();
const username = (route.params.username as string).replace("@", "");
const accounts = useAccountSearch(client, username);
watch(accounts, (newValue) => {
if (Array.isArray(newValue)) {
if (!newValue.find((account) => account.acct === username)) {
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 === username) ?? null,
);