Add loading indicator for profile page while fetching user data

This commit is contained in:
MartinBraquet
2026-02-17 19:55:08 +01:00
parent 8df2be1969
commit 494e62720d

View File

@@ -16,6 +16,7 @@ import {CompassLoadingIndicator} from "web/components/widgets/loading-indicator"
export default function ProfilePage() {
const user = useUser()
const {profile} = useProfileByUser(user ?? undefined)
const [showLoading, setShowLoading] = useState(false)
useEffect(() => {
if (user === null || profile === null) {
@@ -23,7 +24,23 @@ export default function ProfilePage() {
}
}, [user])
return user && profile ? <ProfilePageInner user={user} profile={profile}/> : <CompassLoadingIndicator/>
useEffect(() => {
if (!user || !profile) {
const timer = setTimeout(() => {
setShowLoading(true)
}, 3000)
return () => clearTimeout(timer)
} else {
setShowLoading(false)
}
}, [user, profile])
return user && profile ? <ProfilePageInner user={user} profile={profile}/> :
<PageBase trackPageView={'profile'}>
<Col className="items-center">
{showLoading ? <CompassLoadingIndicator/> : null}
</Col>
</PageBase>
}
function ProfilePageInner(props: { user: User; profile: Profile }) {