From fc783b9ab7a1644261ce8bb7f670e2fecd03f4b6 Mon Sep 17 00:00:00 2001 From: MartinBraquet Date: Sun, 10 May 2026 14:27:22 +0200 Subject: [PATCH] Clarify `user` assignment in `profile-info.tsx` and remove unused `refreshProfile` prop from ProfileCarousel. --- web/components/profile/profile-info.tsx | 11 ++++++---- web/hooks/use-profile.tsx | 29 +++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/web/components/profile/profile-info.tsx b/web/components/profile/profile-info.tsx index 7ae938e3..671f31ff 100644 --- a/web/components/profile/profile-info.tsx +++ b/web/components/profile/profile-info.tsx @@ -38,13 +38,16 @@ export function ProfileInfo(props: { fromProfilePage?: Profile fromSignup?: boolean }) { - const {profile, user, refreshProfile, fromProfilePage, fromSignup} = props - debug('Rendering Profile for', user.username, user.name, props) + const {profile, refreshProfile, fromProfilePage, fromSignup} = props const currentUser = useUser() const t = useT() // const currentProfile = useProfile() - // const isCurrentUser = currentUser?.id === user.id + + const isCurrentUser = currentUser?.id === props.user.id + const user = isCurrentUser ? currentUser : props.user // to refresh user info after update + + debug('Rendering Profile for', user.username, user.name, props) const {data: starredUsers, refresh: refreshStars} = useGetter('stars', currentUser?.id, getStars) const starredUserIds = starredUsers?.map((u) => u.id) @@ -319,7 +322,7 @@ function ProfileContent(props: { {currentUser && ( // - + // )} diff --git a/web/hooks/use-profile.tsx b/web/hooks/use-profile.tsx index 6f674450..35ce21be 100644 --- a/web/hooks/use-profile.tsx +++ b/web/hooks/use-profile.tsx @@ -99,3 +99,32 @@ export const useProfileByUserId = (userId: string | undefined) => { return profile } +// +// async function getUserById(userId: string) { +// const userRes = await run( +// db +// .from('users') +// .select(`id, name, username, created_time, avatar_url, is_banned_from_posting`) +// .eq('id', userId), +// ) +// const user = userRes.data?.[0] +// if (!user) return null +// return convertPartialUser(user) +// } +// +// export const useUserById = (userId: string | undefined) => { +// const [user, setUser] = usePersistentInMemoryState( +// undefined, +// `user-${userId}`, +// ) +// +// useEffect(() => { +// if (userId) { +// getUserById(userId).then((user) => { +// setUser(user ?? null) +// }) +// } +// }, [userId]) +// +// return user +// }