Skip to content

Commit bbbcc93

Browse files
committed
Revert "Update DashboardGovernanceActions.tsx - removes double filtering of proposals"
This reverts commit 6f45edd.
1 parent 75f6161 commit bbbcc93

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

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

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,29 @@ export const DashboardGovernanceActions = () => {
111111
const shouldFilter =
112112
voter?.isRegisteredAsDRep || voter?.isRegisteredAsSoleVoter;
113113

114-
const filteredProposals = proposals;
114+
const filteredProposals = useMemo(() => {
115+
if (!shouldFilter || !proposals || !votes) return proposals;
116+
117+
return proposals
118+
.map((proposalCategory) => {
119+
const filteredActions = proposalCategory.actions.filter((action) => {
120+
const hasVote = votes.some((voteCategory) =>
121+
voteCategory.actions.some(
122+
(voteAction) =>
123+
voteAction.proposal.txHash === action.txHash &&
124+
voteAction.proposal.index === action.index,
125+
),
126+
);
127+
return !hasVote;
128+
});
129+
130+
return {
131+
...proposalCategory,
132+
actions: filteredActions,
133+
};
134+
})
135+
.filter((category) => category.actions.length > 0);
136+
}, [proposals, votes, shouldFilter]);
115137

116138
const { state } = useLocation();
117139
const [content, setContent] = useState<number>(

0 commit comments

Comments
 (0)