Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions govtool/backend/src/VVA/API.hs
Original file line number Diff line number Diff line change
Expand Up @@ -401,9 +401,12 @@ listProposals selectedTypes sortMode mPage mPageSize mDrepRaw mSearchQuery = do
-- proposals that the provided Drep has already voted on should be filtered out
proposalsToRemove <- case mDrepRaw of
Nothing -> return []
Just drepId ->
map (voteParamsProposalId . voteResponseVote)
<$> getVotes drepId [] Nothing Nothing
Just drepId -> do
votes <- getVotes drepId [] Nothing Nothing
return
[ (proposalResponseTxHash p, proposalResponseIndex p)
| VoteResponse{voteResponseProposal = p} <- votes
]

CacheEnv {proposalListCache} <- asks vvaCache

Expand All @@ -412,9 +415,9 @@ listProposals selectedTypes sortMode mPage mPageSize mDrepRaw mSearchQuery = do

mappedSortedAndFilteredProposals <- mapSortAndFilterProposals selectedTypes sortMode proposals
let filteredProposals = filter
( \p@ProposalResponse {proposalResponseId} ->
proposalResponseId `notElem` proposalsToRemove
&& isProposalSearchedFor mSearchQuery p
(\p@ProposalResponse{proposalResponseTxHash, proposalResponseIndex} ->
(proposalResponseTxHash, proposalResponseIndex) `notElem` proposalsToRemove
&& isProposalSearchedFor mSearchQuery p
) mappedSortedAndFilteredProposals

let total = length filteredProposals :: Int
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState, useEffect, useCallback } from "react";
import { useState, useEffect, useCallback, useMemo } from "react";
import { Box, CircularProgress, Tab, Tabs, styled } from "@mui/material";
import { useLocation, useNavigate } from "react-router-dom";

Expand Down Expand Up @@ -107,7 +107,33 @@ export const DashboardGovernanceActions = () => {
debouncedSearchText,
);

const filteredProposals = proposals;
// 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]);

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