Show "Profile not found" text if profile does not exist

This commit is contained in:
silverpill 2022-09-16 00:00:29 +00:00
parent 58419379f0
commit c91b8380a4

View file

@ -1,7 +1,10 @@
<template> <template>
<sidebar-layout v-if="profile"> <sidebar-layout>
<template #content> <template #content>
<div class="profile-block"> <div class="not-found" v-if="!profile && !isLoading">
Profile not found
</div>
<div class="profile-block" v-if="profile">
<div class="profile-header"> <div class="profile-header">
<img v-if="profile.header" :src="profile.header"> <img v-if="profile.header" :src="profile.header">
</div> </div>
@ -160,7 +163,7 @@
</component> </component>
</div> </div>
</div> </div>
<div class="tab-bar"> <div class="tab-bar" v-if="profile">
<template v-if="tabName === 'posts' || tabName === 'posts-with-replies'"> <template v-if="tabName === 'posts' || tabName === 'posts-with-replies'">
<a <a
:class="{ active: tabName === 'posts' }" :class="{ active: tabName === 'posts' }"
@ -260,11 +263,21 @@ let followList = $ref<Profile[]>([])
let followListNextPageUrl = $ref<string | null>(null) let followListNextPageUrl = $ref<string | null>(null)
onMounted(async () => { onMounted(async () => {
isLoading = true
try {
const _profile = await getProfile( const _profile = await getProfile(
authToken, authToken,
route.params.profileId as string, route.params.profileId as string,
) )
profile = new ProfileWrapper(_profile) profile = new ProfileWrapper(_profile)
} catch (error: any) {
if (error.message === "profile not found") {
// Show "not found" text
isLoading = false
return
}
throw error
}
if (currentUser && !isCurrentUser()) { if (currentUser && !isCurrentUser()) {
relationship = await getRelationship( relationship = await getRelationship(
ensureAuthToken(), ensureAuthToken(),
@ -272,6 +285,7 @@ onMounted(async () => {
) )
} }
await switchTab("posts") await switchTab("posts")
isLoading = false
}) })
async function switchTab(name: string) { async function switchTab(name: string) {
@ -735,4 +749,9 @@ $avatar-size: 170px;
.loader { .loader {
margin: 0 auto; margin: 0 auto;
} }
.not-found {
font-size: 20px;
text-align: center;
}
</style> </style>