Skip to content

Commit 48eb152

Browse files
authored
Merge pull request #3933 from IntersectMBO/develop
P0 - 3918 disappearing data ToVote
2 parents 3d20905 + 2c55c4d commit 48eb152

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

govtool/frontend/src/components/organisms/DashboardGovernanceActions.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
DashboardGovernanceActionsVotedOn,
2323
} from "@organisms";
2424
import { Button } from "@atoms";
25+
import usePrevious from "@/hooks/usePrevious";
2526

2627
type TabPanelProps = {
2728
children?: React.ReactNode;
@@ -84,11 +85,17 @@ export const DashboardGovernanceActions = () => {
8485
const queryFilters =
8586
chosenFilters.length > 0 ? chosenFilters : defaultCategories;
8687

88+
const prevFilters = usePrevious(queryFilters);
89+
const prevSorting = usePrevious(chosenSorting);
90+
91+
const stableFilters = isAdjusting ? prevFilters ?? queryFilters : queryFilters;
92+
const stableSorting = isAdjusting ? prevSorting ?? chosenSorting : chosenSorting;
93+
8794
const { proposals, isProposalsLoading } = useGetProposalsQuery({
88-
filters: queryFilters,
89-
sorting: chosenSorting,
95+
filters: stableFilters,
96+
sorting: stableSorting,
9097
searchPhrase: debouncedSearchText,
91-
enabled: !isAdjusting,
98+
enabled: true,
9299
});
93100
const { data: votes, areDRepVotesLoading } = useGetDRepVotesQuery(
94101
queryFilters,

govtool/frontend/src/hooks/queries/useGetProposalsQuery.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,16 @@ export const useGetProposalsQuery = ({
3333
return allProposals.flatMap((proposal) => proposal.elements);
3434
};
3535

36-
const { data, isLoading } = useQuery(
37-
[QUERY_KEYS.useGetProposalsKey, filters, searchPhrase, sorting, dRepID],
38-
fetchProposals,
39-
{
40-
enabled,
41-
refetchOnWindowFocus: true,
42-
keepPreviousData: true,
43-
},
44-
);
36+
const { data, isLoading } = useQuery(
37+
[QUERY_KEYS.useGetProposalsKey, filters, searchPhrase, sorting, dRepID],
38+
fetchProposals,
39+
{
40+
enabled,
41+
refetchOnWindowFocus: true,
42+
keepPreviousData: true,
43+
staleTime: 2000,
44+
},
45+
);
4546

4647
const proposals = Object.values(groupByType(data) ?? []);
4748

0 commit comments

Comments
 (0)