Clarify user assignment in profile-info.tsx and remove unused refreshProfile prop from ProfileCarousel.

This commit is contained in:
MartinBraquet
2026-05-10 14:27:22 +02:00
parent 5fee7a3686
commit fc783b9ab7
2 changed files with 36 additions and 4 deletions

View File

@@ -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 && (
// <ProfileCard className="!p-0">
<ProfileCarousel profile={profile} refreshProfile={refreshProfile} />
<ProfileCarousel profile={profile} />
// </ProfileCard>
)}

View File

@@ -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<User | undefined | null>(
// undefined,
// `user-${userId}`,
// )
//
// useEffect(() => {
// if (userId) {
// getUserById(userId).then((user) => {
// setUser(user ?? null)
// })
// }
// }, [userId])
//
// return user
// }