Skip to content

Commit 2d0372a

Browse files
committed
TCA-1193 - fix user profile fetch for tca certification
1 parent c1f62ab commit 2d0372a

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

src-ts/tools/learn/tca-certificate/user-certification-view/use-get-user-profile.tsx

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { Dispatch, SetStateAction, useContext, useEffect, useState } from 'react'
1+
import { Dispatch, SetStateAction, useEffect, useState } from 'react'
22

3-
import { profileContext, ProfileContextData, profileGetPublicAsync, UserProfile } from '../../../../lib'
3+
import { profileGetPublicAsync, UserProfile } from '../../../../lib'
44

55
export interface UseGetUserProfileData {
66
isOwnProfile: boolean
@@ -9,8 +9,6 @@ export interface UseGetUserProfileData {
99
}
1010

1111
export function useGetUserProfile(memberHandle?: string): UseGetUserProfileData {
12-
const profileData: ProfileContextData = useContext(profileContext)
13-
1412
const [profile, setProfile]: [
1513
UserProfile | undefined,
1614
Dispatch<SetStateAction<UserProfile | undefined>>
@@ -19,21 +17,14 @@ export function useGetUserProfile(memberHandle?: string): UseGetUserProfileData
1917
const [profileReady, setProfileReady]: [boolean, Dispatch<SetStateAction<boolean>>] = useState<boolean>(false)
2018

2119
useEffect(() => {
22-
if (!profileData?.initialized) {
23-
return
24-
}
25-
26-
if (profileData.profile) {
27-
setProfile(profileData.profile)
28-
setProfileReady(true)
29-
} else if (memberHandle) {
20+
if (memberHandle) {
3021
profileGetPublicAsync(memberHandle)
3122
.then(userProfile => {
3223
setProfile(userProfile)
3324
setProfileReady(true)
3425
})
3526
}
36-
}, [memberHandle, profileData?.initialized, profileData.profile, setProfileReady])
27+
}, [memberHandle, setProfileReady])
3728

3829
return {
3930
isOwnProfile: !!profile?.email,

0 commit comments

Comments
 (0)