Skip to content

Commit

Permalink
fix: useSearchedProjectsDetails for projects before AW opens
Browse files Browse the repository at this point in the history
  • Loading branch information
aziolek committed Jan 10, 2025
1 parent 5f08e95 commit a69e0a3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion client/src/hooks/queries/useSearchedProjectsDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ export default function useSearchedProjectsDetails(
const projectsEpoch = await apiGetProjects(Number(projectsSearchResult.epoch));
const shouldFetchEstimatedRewards =
projectsSearchResult.epoch === currentEpoch! - 1 && !!isDecisionWindowOpen;
/**
* apiGetMatchedProjectRewards can be called only after AW is closed.
* Calling it before AW opens results in 500 from BE (snapshot not taken)
*/
const shouldFetchMatchedProjectRewards =
!shouldFetchEstimatedRewards && currentEpoch! > projectsSearchResult.epoch;
return Promise.all([
projectsSearchResult.epoch,
projectsSearchResult.address,
Expand All @@ -70,7 +76,7 @@ export default function useSearchedProjectsDetails(
? apiGetAllocationsPerProject(projectsSearchResult.address, projectsSearchResult.epoch)
: undefined,
shouldFetchEstimatedRewards ? apiGetEstimatedMatchedProjectRewards() : undefined,
!shouldFetchEstimatedRewards
shouldFetchMatchedProjectRewards
? apiGetMatchedProjectRewards(projectsSearchResult.epoch)
: undefined,
]);
Expand Down

0 comments on commit a69e0a3

Please sign in to comment.