From 37f8deab3f739b25759077ac80dab83c32fabc12 Mon Sep 17 00:00:00 2001 From: Henry Palacios Date: Wed, 3 Nov 2021 12:21:47 -0300 Subject: [PATCH 1/2] Remove Loading Component added on 1753 --- src/custom/hooks/useFetchProfile.ts | 5 +++-- src/custom/pages/Profile/index.tsx | 25 +++++++++++++++++++------ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/custom/hooks/useFetchProfile.ts b/src/custom/hooks/useFetchProfile.ts index e49393102..3fa1bf141 100644 --- a/src/custom/hooks/useFetchProfile.ts +++ b/src/custom/hooks/useFetchProfile.ts @@ -5,13 +5,13 @@ import { ProfileData } from 'api/gnosisProtocol/api' type FetchProfileState = { profileData: ProfileData | null - //error: string + error: string isLoading: boolean } const emptyState: FetchProfileState = { profileData: null, - //error: '', + error: '', isLoading: false, } @@ -22,6 +22,7 @@ export default function useFetchProfile(): FetchProfileState { const [profile, setProfile] = useState(emptyState) useEffect(() => { + setProfile({ ...emptyState, isLoading: true }) async function fetchAndSetProfileData() { try { if (chainId && account) { diff --git a/src/custom/pages/Profile/index.tsx b/src/custom/pages/Profile/index.tsx index 06ebb22a5..f2cda534f 100644 --- a/src/custom/pages/Profile/index.tsx +++ b/src/custom/pages/Profile/index.tsx @@ -26,9 +26,26 @@ import { SupportedChainId as ChainId } from 'constants/chains' export default function Profile() { const referralLink = useReferralLink() const { account, chainId } = useActiveWeb3React() - const { profileData, isLoading } = useFetchProfile() + const { profileData, isLoading, error } = useFetchProfile() const lastUpdated = useTimeAgo(profileData?.lastUpdated) + const renderNotificationMessages = () => { + return ( + <> + {error && ( + + There was an error loading your profile data. Please try again later. + + )} + {chainId && chainId !== ChainId.MAINNET && ( + + Profile data is only available for mainnet. Please change the network to see it. + + )} + + ) + } + return ( @@ -57,11 +74,7 @@ export default function Profile() { )} - {chainId && chainId !== ChainId.MAINNET && ( - - Profile data is only available for mainnet. Please change the network to see it. - - )} + {renderNotificationMessages()} Your referral url From 2cda92f8209995d86ea4dcd21cc3a08db1550d16 Mon Sep 17 00:00:00 2001 From: Henry Palacios Date: Thu, 4 Nov 2021 10:07:51 -0300 Subject: [PATCH 2/2] Fix merging errors --- src/custom/hooks/useFetchProfile.ts | 1 - src/custom/pages/Profile/index.tsx | 32 ++++++++++++++--------------- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/custom/hooks/useFetchProfile.ts b/src/custom/hooks/useFetchProfile.ts index 3fa1bf141..c2d95af4e 100644 --- a/src/custom/hooks/useFetchProfile.ts +++ b/src/custom/hooks/useFetchProfile.ts @@ -22,7 +22,6 @@ export default function useFetchProfile(): FetchProfileState { const [profile, setProfile] = useState(emptyState) useEffect(() => { - setProfile({ ...emptyState, isLoading: true }) async function fetchAndSetProfileData() { try { if (chainId && account) { diff --git a/src/custom/pages/Profile/index.tsx b/src/custom/pages/Profile/index.tsx index f2cda534f..679dd331c 100644 --- a/src/custom/pages/Profile/index.tsx +++ b/src/custom/pages/Profile/index.tsx @@ -29,22 +29,20 @@ export default function Profile() { const { profileData, isLoading, error } = useFetchProfile() const lastUpdated = useTimeAgo(profileData?.lastUpdated) - const renderNotificationMessages = () => { - return ( - <> - {error && ( - - There was an error loading your profile data. Please try again later. - - )} - {chainId && chainId !== ChainId.MAINNET && ( - - Profile data is only available for mainnet. Please change the network to see it. - - )} - - ) - } + const renderNotificationMessages = ( + <> + {error && ( + + There was an error loading your profile data. Please try again later. + + )} + {chainId && chainId !== ChainId.MAINNET && ( + + Profile data is only available for mainnet. Please change the network to see it. + + )} + + ) return ( @@ -74,7 +72,7 @@ export default function Profile() { )} - {renderNotificationMessages()} + {renderNotificationMessages} Your referral url