From 8fc760822b7f01d3f84dc002da9e126009c0e051 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Sza=C5=82owski?= Date: Fri, 3 Jan 2025 13:41:36 +0100 Subject: [PATCH] fix(#2535): fix bad request on ga list --- CHANGELOG.md | 1 + .../src/components/organisms/DashboardGovernanceActions.tsx | 4 +++- govtool/frontend/src/context/dataActionsBar.tsx | 6 ++++++ govtool/frontend/src/hooks/queries/useGetProposalsQuery.ts | 4 ++++ govtool/frontend/src/services/requests/getProposals.ts | 1 + 5 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c7b20fe3..996d791ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ changes. ### Fixed - Fix CIP-129 DRep view identifier for script based DReps [Issue 2583](https://github.com/IntersectMBO/govtool/issues/2583) +- Fix bad request on passing the random sorting to GA list request [Issue 2535](https://github.com/IntersectMBO/govtool/issues/2535) ### Changed diff --git a/govtool/frontend/src/components/organisms/DashboardGovernanceActions.tsx b/govtool/frontend/src/components/organisms/DashboardGovernanceActions.tsx index 45b466475..3bcf8bb90 100644 --- a/govtool/frontend/src/components/organisms/DashboardGovernanceActions.tsx +++ b/govtool/frontend/src/components/organisms/DashboardGovernanceActions.tsx @@ -67,7 +67,8 @@ const StyledTab = styled((props: StyledTabProps) => ( })); export const DashboardGovernanceActions = () => { - const { debouncedSearchText, ...dataActionsBarProps } = useDataActionsBar(); + const { debouncedSearchText, isAdjusting, ...dataActionsBarProps } = + useDataActionsBar(); const { chosenFilters, chosenSorting } = dataActionsBarProps; const { voter } = useGetVoterInfo(); const { isMobile } = useScreenDimension(); @@ -81,6 +82,7 @@ export const DashboardGovernanceActions = () => { filters: queryFilters, sorting: chosenSorting, searchPhrase: debouncedSearchText, + enabled: !isAdjusting, }); const { state } = useLocation(); diff --git a/govtool/frontend/src/context/dataActionsBar.tsx b/govtool/frontend/src/context/dataActionsBar.tsx index e71cbd450..fd18ee55a 100644 --- a/govtool/frontend/src/context/dataActionsBar.tsx +++ b/govtool/frontend/src/context/dataActionsBar.tsx @@ -14,6 +14,7 @@ import { useLocation } from "react-router-dom"; import { useDebounce } from "@hooks"; interface DataActionsBarContextType { + isAdjusting: boolean; chosenFilters: string[]; chosenFiltersLength: number; chosenSorting: string; @@ -40,6 +41,7 @@ interface ProviderProps { } const DataActionsBarProvider: FC = ({ children }) => { + const [isAdjusting, setIsAdjusting] = useState(true); const [searchText, setSearchText] = useState(""); const debouncedSearchText = useDebounce(searchText, 300); const [filtersOpen, setFiltersOpen] = useState(false); @@ -62,6 +64,7 @@ const DataActionsBarProvider: FC = ({ children }) => { setSearchText(""); setChosenFilters([]); setChosenSorting(""); + setIsAdjusting(false); }, []); const userMovedToDifferentAppArea = @@ -74,6 +77,7 @@ const DataActionsBarProvider: FC = ({ children }) => { pathname.includes("governance_actions/category"); useEffect(() => { + setIsAdjusting(true); if ( (!pathname.includes("drep_directory") && userMovedToDifferentAppArea && @@ -90,6 +94,7 @@ const DataActionsBarProvider: FC = ({ children }) => { const contextValue = useMemo( () => ({ + isAdjusting, chosenFilters, chosenFiltersLength: chosenFilters.length, chosenSorting, @@ -106,6 +111,7 @@ const DataActionsBarProvider: FC = ({ children }) => { sortOpen, }), [ + isAdjusting, chosenFilters, chosenSorting, debouncedSearchText, diff --git a/govtool/frontend/src/hooks/queries/useGetProposalsQuery.ts b/govtool/frontend/src/hooks/queries/useGetProposalsQuery.ts index f8f0ce857..6843f76af 100644 --- a/govtool/frontend/src/hooks/queries/useGetProposalsQuery.ts +++ b/govtool/frontend/src/hooks/queries/useGetProposalsQuery.ts @@ -10,6 +10,7 @@ export const useGetProposalsQuery = ({ filters = [], searchPhrase, sorting, + enabled, }: GetProposalsArguments) => { const { dRepID, pendingTransaction } = useCardano(); const { voter } = useGetVoterInfo(); @@ -42,6 +43,9 @@ export const useGetProposalsQuery = ({ pendingTransaction.vote?.transactionHash, ], fetchProposals, + { + enabled, + }, ); const proposals = Object.values(groupByType(data) ?? []); diff --git a/govtool/frontend/src/services/requests/getProposals.ts b/govtool/frontend/src/services/requests/getProposals.ts index 9e9fef4d0..9d09751be 100644 --- a/govtool/frontend/src/services/requests/getProposals.ts +++ b/govtool/frontend/src/services/requests/getProposals.ts @@ -14,6 +14,7 @@ export type GetProposalsArguments = { pageSize?: number; sorting?: string; searchPhrase?: string; + enabled?: boolean; }; export const getProposals = async ({