diff --git a/govtool/frontend/src/components/organisms/DashboardGovernanceActions.tsx b/govtool/frontend/src/components/organisms/DashboardGovernanceActions.tsx index c129179a9..838123327 100644 --- a/govtool/frontend/src/components/organisms/DashboardGovernanceActions.tsx +++ b/govtool/frontend/src/components/organisms/DashboardGovernanceActions.tsx @@ -107,11 +107,14 @@ export const DashboardGovernanceActions = () => { debouncedSearchText, ); - // TODO: Black magic - that filtering should be done on the backend - const filteredProposals = proposals + // White Magic :) + const filterOutAlreadyVotedProposals = () => { + if (!votes) return proposals; + + return proposals ?.map((proposalCategory) => { const filteredActions = proposalCategory.actions.filter((action) => { - const hasVote = votes?.some((voteCategory) => + const hasVote = votes.some((voteCategory) => voteCategory.actions.some( (voteAction) => voteAction.proposal.txHash === action.txHash && @@ -128,6 +131,9 @@ export const DashboardGovernanceActions = () => { }; }) .filter((category) => category.actions.length > 0); +}; + +const filteredProposals = filterOutAlreadyVotedProposals(); const { state } = useLocation(); const [content, setContent] = useState(