diff --git a/client/src/components/Earn/EarnHistory/EarnHistoryItemDetails/EarnHistoryItemDetailsAllocation/EarnHistoryItemDetailsAllocation.tsx b/client/src/components/Earn/EarnHistory/EarnHistoryItemDetails/EarnHistoryItemDetailsAllocation/EarnHistoryItemDetailsAllocation.tsx index 8d4d2943e..2caa26a18 100644 --- a/client/src/components/Earn/EarnHistory/EarnHistoryItemDetails/EarnHistoryItemDetailsAllocation/EarnHistoryItemDetailsAllocation.tsx +++ b/client/src/components/Earn/EarnHistory/EarnHistoryItemDetails/EarnHistoryItemDetailsAllocation/EarnHistoryItemDetailsAllocation.tsx @@ -29,12 +29,12 @@ const EarnHistoryItemDetailsAllocation: FC ))} diff --git a/client/src/components/shared/ProjectAllocationDetailRow/ProjectAllocationDetailRow.tsx b/client/src/components/shared/ProjectAllocationDetailRow/ProjectAllocationDetailRow.tsx index dbf33d8c3..e36cbe80c 100644 --- a/client/src/components/shared/ProjectAllocationDetailRow/ProjectAllocationDetailRow.tsx +++ b/client/src/components/shared/ProjectAllocationDetailRow/ProjectAllocationDetailRow.tsx @@ -15,6 +15,7 @@ const ProjectAllocationDetailRow: FC = ({ address, amount, epoch, + isLoading, }) => { const { ipfsGateways } = env; const { @@ -29,10 +30,12 @@ const ProjectAllocationDetailRow: FC = ({ const { data: projectIpfs, isFetching: isFetchingProjectIpfs } = useProjectsIpfs( [address], epoch, + !isLoading, ); + return (
- {isFetchingProjectIpfs ? ( + {isLoading || isFetchingProjectIpfs ? (
) : ( diff --git a/client/src/components/shared/ProjectAllocationDetailRow/types.ts b/client/src/components/shared/ProjectAllocationDetailRow/types.ts index 49c8a175c..09fa5f734 100644 --- a/client/src/components/shared/ProjectAllocationDetailRow/types.ts +++ b/client/src/components/shared/ProjectAllocationDetailRow/types.ts @@ -2,4 +2,5 @@ export default interface ProjectAllocationDetailRowProps { address: string; amount: bigint; epoch?: number; + isLoading: boolean; } diff --git a/client/src/hooks/queries/useProjectsEpoch.ts b/client/src/hooks/queries/useProjectsEpoch.ts index fadf32be9..3466aa543 100644 --- a/client/src/hooks/queries/useProjectsEpoch.ts +++ b/client/src/hooks/queries/useProjectsEpoch.ts @@ -1,4 +1,4 @@ -import { UseQueryResult, useQuery } from '@tanstack/react-query'; +import { UseQueryResult, useQuery, UseQueryOptions } from '@tanstack/react-query'; import { apiGetProjects, Projects } from 'api/calls/projects'; import { QUERY_KEYS } from 'api/queryKeys'; @@ -6,7 +6,10 @@ import { QUERY_KEYS } from 'api/queryKeys'; import useCurrentEpoch from './useCurrentEpoch'; import useIsDecisionWindowOpen from './useIsDecisionWindowOpen'; -export default function useProjectsEpoch(epoch?: number): UseQueryResult { +export default function useProjectsEpoch( + epoch?: number, + options?: Omit, 'queryKey'>, +): UseQueryResult { const { data: isDecisionWindowOpen } = useIsDecisionWindowOpen(); const { data: currentEpoch } = useCurrentEpoch(); @@ -19,5 +22,6 @@ export default function useProjectsEpoch(epoch?: number): UseQueryResult apiGetProjects(epochToUse), queryKey: epoch || currentEpoch ? QUERY_KEYS.projectsEpoch(epochToUse) : [''], + ...options, }); } diff --git a/client/src/hooks/queries/useProjectsIpfs.ts b/client/src/hooks/queries/useProjectsIpfs.ts index ab2749ff1..60bcae866 100644 --- a/client/src/hooks/queries/useProjectsIpfs.ts +++ b/client/src/hooks/queries/useProjectsIpfs.ts @@ -14,6 +14,7 @@ import useProjectsEpoch from './useProjectsEpoch'; export default function useProjectsIpfs( projectsAddresses?: string[], epoch?: number, + isEnabled?: boolean, ): { data: ExtendedProject[]; isFetching: boolean; refetch: () => void } { const { t } = useTranslation('translation', { keyPrefix: 'api.errorMessage' }); const { data: currentEpoch } = useCurrentEpoch(); @@ -21,7 +22,7 @@ export default function useProjectsIpfs( data: projectsEpoch, refetch, isFetching: isFetchingProjectsEpoch, - } = useProjectsEpoch(epoch); + } = useProjectsEpoch(epoch, { enabled: isEnabled }); const projectsIpfsResults: UseQueryResult[] = useQueries({