From 2d0372a0827d05e7988bc88ab34768e648abd234 Mon Sep 17 00:00:00 2001 From: Vasilica Olariu Date: Thu, 23 Mar 2023 10:27:53 +0200 Subject: [PATCH] TCA-1193 - fix user profile fetch for tca certification --- .../use-get-user-profile.tsx | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src-ts/tools/learn/tca-certificate/user-certification-view/use-get-user-profile.tsx b/src-ts/tools/learn/tca-certificate/user-certification-view/use-get-user-profile.tsx index c4379c544..3d38e44d5 100644 --- a/src-ts/tools/learn/tca-certificate/user-certification-view/use-get-user-profile.tsx +++ b/src-ts/tools/learn/tca-certificate/user-certification-view/use-get-user-profile.tsx @@ -1,6 +1,6 @@ -import { Dispatch, SetStateAction, useContext, useEffect, useState } from 'react' +import { Dispatch, SetStateAction, useEffect, useState } from 'react' -import { profileContext, ProfileContextData, profileGetPublicAsync, UserProfile } from '../../../../lib' +import { profileGetPublicAsync, UserProfile } from '../../../../lib' export interface UseGetUserProfileData { isOwnProfile: boolean @@ -9,8 +9,6 @@ export interface UseGetUserProfileData { } export function useGetUserProfile(memberHandle?: string): UseGetUserProfileData { - const profileData: ProfileContextData = useContext(profileContext) - const [profile, setProfile]: [ UserProfile | undefined, Dispatch> @@ -19,21 +17,14 @@ export function useGetUserProfile(memberHandle?: string): UseGetUserProfileData const [profileReady, setProfileReady]: [boolean, Dispatch>] = useState(false) useEffect(() => { - if (!profileData?.initialized) { - return - } - - if (profileData.profile) { - setProfile(profileData.profile) - setProfileReady(true) - } else if (memberHandle) { + if (memberHandle) { profileGetPublicAsync(memberHandle) .then(userProfile => { setProfile(userProfile) setProfileReady(true) }) } - }, [memberHandle, profileData?.initialized, profileData.profile, setProfileReady]) + }, [memberHandle, setProfileReady]) return { isOwnProfile: !!profile?.email,