From 5bbec7ba55f4572e7f81542431932a1f7ff23746 Mon Sep 17 00:00:00 2001 From: Miro Date: Sat, 26 Jul 2025 22:25:25 +0200 Subject: [PATCH] Fix search for wallet without dRep --- .../organisms/DashboardGovernanceActions.tsx | 67 ++++++++----------- 1 file changed, 28 insertions(+), 39 deletions(-) diff --git a/govtool/frontend/src/components/organisms/DashboardGovernanceActions.tsx b/govtool/frontend/src/components/organisms/DashboardGovernanceActions.tsx index b720ec2f4..101ec0f52 100644 --- a/govtool/frontend/src/components/organisms/DashboardGovernanceActions.tsx +++ b/govtool/frontend/src/components/organisms/DashboardGovernanceActions.tsx @@ -22,7 +22,6 @@ import { DashboardGovernanceActionsVotedOn, } from "@organisms"; import { Button } from "@atoms"; -import usePrevious from "@/hooks/usePrevious"; type TabPanelProps = { children?: React.ReactNode; @@ -85,21 +84,11 @@ export const DashboardGovernanceActions = () => { const queryFilters = chosenFilters.length > 0 ? chosenFilters : defaultCategories; - const prevFilters = usePrevious(queryFilters); - const prevSorting = usePrevious(chosenSorting); - - const stableFilters = isAdjusting - ? prevFilters ?? queryFilters - : queryFilters; - const stableSorting = isAdjusting - ? prevSorting ?? chosenSorting - : chosenSorting; - const { proposals, isProposalsLoading } = useGetProposalsQuery({ - filters: stableFilters, - sorting: stableSorting, + filters: queryFilters, + sorting: chosenSorting, searchPhrase: debouncedSearchText, - enabled: voter?.isRegisteredAsDRep || voter?.isRegisteredAsSoleVoter, + enabled: !isAdjusting, }); const { data: votes, areDRepVotesLoading } = useGetDRepVotesQuery( queryFilters, @@ -109,31 +98,31 @@ export const DashboardGovernanceActions = () => { // White Magic :) const shouldFilter = - voter?.isRegisteredAsDRep || voter?.isRegisteredAsSoleVoter; - -const filteredProposals = useMemo(() => { - if (!shouldFilter || !proposals || !votes) return proposals; - - return proposals - .map((proposalCategory) => { - const filteredActions = proposalCategory.actions.filter((action) => { - const hasVote = votes.some((voteCategory) => - voteCategory.actions.some( - (voteAction) => - voteAction.proposal.txHash === action.txHash && - voteAction.proposal.index === action.index, - ), - ); - return !hasVote; - }); - - return { - ...proposalCategory, - actions: filteredActions, - }; - }) - .filter((category) => category.actions.length > 0); -}, [proposals, votes, shouldFilter]); + voter?.isRegisteredAsDRep || voter?.isRegisteredAsSoleVoter; + + const filteredProposals = useMemo(() => { + if (!shouldFilter || !proposals || !votes) return proposals; + + return proposals + .map((proposalCategory) => { + const filteredActions = proposalCategory.actions.filter((action) => { + const hasVote = votes.some((voteCategory) => + voteCategory.actions.some( + (voteAction) => + voteAction.proposal.txHash === action.txHash && + voteAction.proposal.index === action.index, + ), + ); + return !hasVote; + }); + + return { + ...proposalCategory, + actions: filteredActions, + }; + }) + .filter((category) => category.actions.length > 0); + }, [proposals, votes, shouldFilter]); const { state } = useLocation(); const [content, setContent] = useState(