Skip to content

Commit 1bfde50

Browse files
authored
[HOTFIX] Correct epoch passed to fetch assets in history (#180)
2 parents a32cf5f + 3ff6c5c commit 1bfde50

File tree

5 files changed

+18
-8
lines changed

5 files changed

+18
-8
lines changed

client/src/components/Earn/EarnHistory/EarnHistoryItemDetails/EarnHistoryItemDetailsAllocation/EarnHistoryItemDetailsAllocation.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ const EarnHistoryItemDetailsAllocation: FC<EarnHistoryItemDetailsAllocationProps
2929
const { data: isDecisionWindowOpen } = useIsDecisionWindowOpen();
3030
const { data: epochTimestampHappenedIn, isFetching: isFetchingEpochTimestampHappenedIn } =
3131
useEpochTimestampHappenedIn(timestamp);
32-
const { data: epochLeverage, isFetching: isFetchingEpochLeverage } = useEpochLeverage(
33-
epochTimestampHappenedIn ? epochTimestampHappenedIn - 1 : undefined,
34-
);
3532

3633
const allocationEpoch = epochTimestampHappenedIn ? epochTimestampHappenedIn - 1 : undefined;
3734

35+
const { data: epochLeverage, isFetching: isFetchingEpochLeverage } =
36+
useEpochLeverage(allocationEpoch);
37+
3838
const { data: individualReward, isFetching: isFetchingIndividualReward } =
3939
useIndividualReward(allocationEpoch);
4040

@@ -132,7 +132,8 @@ const EarnHistoryItemDetailsAllocation: FC<EarnHistoryItemDetailsAllocationProps
132132
<ProjectAllocationDetailRow
133133
key={allocation.address}
134134
{...allocation}
135-
epoch={epochTimestampHappenedIn}
135+
epoch={allocationEpoch}
136+
isLoading={isFetchingEpochTimestampHappenedIn}
136137
/>
137138
))}
138139
</BoxRounded>

client/src/components/shared/ProjectAllocationDetailRow/ProjectAllocationDetailRow.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const ProjectAllocationDetailRow: FC<ProjectAllocationDetailRowProps> = ({
1515
address,
1616
amount,
1717
epoch,
18+
isLoading,
1819
}) => {
1920
const { ipfsGateways } = env;
2021
const {
@@ -29,10 +30,12 @@ const ProjectAllocationDetailRow: FC<ProjectAllocationDetailRowProps> = ({
2930
const { data: projectIpfs, isFetching: isFetchingProjectIpfs } = useProjectsIpfs(
3031
[address],
3132
epoch,
33+
!isLoading,
3234
);
35+
3336
return (
3437
<div className={styles.root}>
35-
{isFetchingProjectIpfs ? (
38+
{isLoading || isFetchingProjectIpfs ? (
3639
<div className={styles.skeleton} />
3740
) : (
3841
<Fragment>

client/src/components/shared/ProjectAllocationDetailRow/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ export default interface ProjectAllocationDetailRowProps {
22
address: string;
33
amount: bigint;
44
epoch?: number;
5+
isLoading: boolean;
56
}

client/src/hooks/queries/useProjectsEpoch.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
import { UseQueryResult, useQuery } from '@tanstack/react-query';
1+
import { UseQueryResult, useQuery, UseQueryOptions } from '@tanstack/react-query';
22

33
import { apiGetProjects, Projects } from 'api/calls/projects';
44
import { QUERY_KEYS } from 'api/queryKeys';
55

66
import useCurrentEpoch from './useCurrentEpoch';
77
import useIsDecisionWindowOpen from './useIsDecisionWindowOpen';
88

9-
export default function useProjectsEpoch(epoch?: number): UseQueryResult<Projects, unknown> {
9+
export default function useProjectsEpoch(
10+
epoch?: number,
11+
options?: Omit<UseQueryOptions<Projects, unknown, Projects, any>, 'queryKey'>,
12+
): UseQueryResult<Projects, unknown> {
1013
const { data: isDecisionWindowOpen } = useIsDecisionWindowOpen();
1114
const { data: currentEpoch } = useCurrentEpoch();
1215

@@ -19,5 +22,6 @@ export default function useProjectsEpoch(epoch?: number): UseQueryResult<Project
1922

2023
queryFn: () => apiGetProjects(epochToUse),
2124
queryKey: epoch || currentEpoch ? QUERY_KEYS.projectsEpoch(epochToUse) : [''],
25+
...options,
2226
});
2327
}

client/src/hooks/queries/useProjectsIpfs.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@ import useProjectsEpoch from './useProjectsEpoch';
1414
export default function useProjectsIpfs(
1515
projectsAddresses?: string[],
1616
epoch?: number,
17+
isEnabled?: boolean,
1718
): { data: ExtendedProject[]; isFetching: boolean; refetch: () => void } {
1819
const { t } = useTranslation('translation', { keyPrefix: 'api.errorMessage' });
1920
const { data: currentEpoch } = useCurrentEpoch();
2021
const {
2122
data: projectsEpoch,
2223
refetch,
2324
isFetching: isFetchingProjectsEpoch,
24-
} = useProjectsEpoch(epoch);
25+
} = useProjectsEpoch(epoch, { enabled: isEnabled });
2526

2627
const projectsIpfsResults: UseQueryResult<BackendProposal & { ipfsGatewayUsed: string }>[] =
2728
useQueries({

0 commit comments

Comments
 (0)