1+ import { NotFoundContent } from "@client/components/common/404"
12import { FeedIcon } from "@client/components/ui/feed-icon"
23import { openInFollowApp } from "@client/lib/helper"
34import { UrlBuilder } from "@client/lib/url-builder"
@@ -10,6 +11,7 @@ import { LoadingCircle } from "@follow/components/ui/loading/index.jsx"
1011import { useTitle } from "@follow/hooks"
1112import { cn } from "@follow/utils/utils"
1213import type { SubscriptionWithFeed , UserProfile } from "@follow-app/client-sdk"
14+ import { FollowAPIError } from "@follow-app/client-sdk"
1315import * as React from "react"
1416import { Fragment , memo , useState } from "react"
1517import { useParams } from "react-router"
@@ -89,22 +91,43 @@ export const Component = () => {
8991
9092 useTitle ( user . data ?. name )
9193
94+ if ( user . isLoading ) {
95+ return < LoadingCircle size = "large" className = "center fixed inset-0" />
96+ }
97+
98+ if ( ! user . data ) {
99+ if ( user . error instanceof FollowAPIError && user . error . status === 404 ) {
100+ return < NotFoundContent />
101+ }
102+
103+ return < ProfileLoadError onRetry = { ( ) => void user . refetch ( ) } />
104+ }
105+
92106 return (
93- < >
94- { user . isLoading ? (
95- < LoadingCircle size = "large" className = "center fixed inset-0" />
96- ) : (
97- < Fragment >
98- < UserHero user = { user . data ! } />
99- < Lists userId = { user . data ?. id } />
100- { /* Subscriptions Section */ }
101- < Subscriptions userId = { user . data ?. id } />
102- </ Fragment >
103- ) }
104- </ >
107+ < Fragment >
108+ < UserHero user = { user . data } />
109+ < Lists userId = { user . data . id } />
110+ { /* Subscriptions Section */ }
111+ < Subscriptions userId = { user . data . id } />
112+ </ Fragment >
105113 )
106114}
107115
116+ const ProfileLoadError = ( { onRetry } : { onRetry : ( ) => void } ) => (
117+ < div className = "mx-auto flex min-h-[60vh] max-w-xl flex-col items-center justify-center px-6 text-center" >
118+ < i className = "i-mgc-warning-fill mb-6 size-12 text-orange-500" />
119+ < h1 className = "text-2xl font-semibold text-zinc-900 dark:text-zinc-100" >
120+ Unable to load this profile
121+ </ h1 >
122+ < p className = "mt-3 text-zinc-500 dark:text-zinc-400" >
123+ This may be a temporary problem. Please try again.
124+ </ p >
125+ < Button buttonClassName = "mt-8" onClick = { onRetry } >
126+ Try again
127+ </ Button >
128+ </ div >
129+ )
130+
108131const UserHero = ( { user } : { user : UserProfile } ) => {
109132 const subscriptions = useUserSubscriptionsQuery ( user . id )
110133
0 commit comments