diff --git a/govtool/backend/src/VVA/API.hs b/govtool/backend/src/VVA/API.hs
index 7c4b3f519..c0a594f7a 100644
--- a/govtool/backend/src/VVA/API.hs
+++ b/govtool/backend/src/VVA/API.hs
@@ -434,7 +434,8 @@ listProposals selectedTypes sortMode mPage mPageSize mDrepRaw mSearchQuery = do
proposalsToRemove <- case mDrepRaw of
Nothing -> return []
Just drepId ->
- map (voteParamsProposalId . voteResponseVote)
+ map (\VoteResponse { voteResponseProposal = ProposalResponse { proposalResponseTxHash, proposalResponseIndex } } ->
+ (proposalResponseTxHash, proposalResponseIndex))
<$> getVotes drepId [] Nothing Nothing
CacheEnv {proposalListCache} <- asks vvaCache
@@ -444,8 +445,8 @@ listProposals selectedTypes sortMode mPage mPageSize mDrepRaw mSearchQuery = do
mappedSortedAndFilteredProposals <- mapSortAndFilterProposals selectedTypes sortMode proposals
let filteredProposals = filter
- ( \p@ProposalResponse {proposalResponseId} ->
- proposalResponseId `notElem` proposalsToRemove
+ (\p@ProposalResponse { proposalResponseTxHash, proposalResponseIndex } ->
+ (proposalResponseTxHash, proposalResponseIndex) `notElem` proposalsToRemove
&& isProposalSearchedFor mSearchQuery p
) mappedSortedAndFilteredProposals
diff --git a/govtool/frontend/src/components/organisms/DashboardGovernanceActionsVotedOn.tsx b/govtool/frontend/src/components/organisms/DashboardGovernanceActionsVotedOn.tsx
index 3c145d98d..be82ad668 100644
--- a/govtool/frontend/src/components/organisms/DashboardGovernanceActionsVotedOn.tsx
+++ b/govtool/frontend/src/components/organisms/DashboardGovernanceActionsVotedOn.tsx
@@ -8,7 +8,6 @@ import {
useTranslation,
} from "@hooks";
import { ValidatedGovernanceVotedOnCard } from "@organisms";
-import { getFullGovActionId } from "@utils";
type DashboardGovernanceActionsVotedOnProps = {
searchPhrase?: string;
@@ -25,41 +24,14 @@ export const DashboardGovernanceActionsVotedOn = ({
const {
data: votes,
- areDRepVotesLoading,
- isFetching,
+ areDRepVotesLoading
} = useGetDRepVotesQuery(chosenFilters, chosenSorting, searchPhrase);
- // TODO: Filtering here is some kind of craziness. It should be done on the backend.
- const filteredData = useMemo(() => {
- if (!votes?.length) return [];
- if (!searchPhrase) return votes.flatMap((entry) => entry.actions);
+ const proposals = useMemo(() =>
+ votes.flatMap((entry) => entry.actions),
+ [votes, searchPhrase, pendingTransaction.vote]);
- const lowerSearch = searchPhrase.toLowerCase();
-
- return votes.flatMap((entry) =>
- entry.actions.filter((action) => {
- const hash = getFullGovActionId(
- action.proposal.txHash,
- action.proposal.index,
- ).toLowerCase();
-
- const title = action.proposal.title?.toLowerCase() || "";
- const motivation = action.proposal.motivation?.toLowerCase() || "";
- const rationale = action.proposal.rationale?.toLowerCase() || "";
- const abstract = action.proposal.abstract?.toLowerCase() || "";
-
- return (
- hash.includes(lowerSearch) ||
- title.includes(lowerSearch) ||
- motivation.includes(lowerSearch) ||
- rationale.includes(lowerSearch) ||
- abstract.includes(lowerSearch)
- );
- }),
- );
- }, [votes, searchPhrase, pendingTransaction.vote]);
-
- return areDRepVotesLoading || isFetching ? (
+ return areDRepVotesLoading ? (
@@ -69,7 +41,7 @@ export const DashboardGovernanceActionsVotedOn = ({
{t("govActions.youHaventVotedYet")}
- ) : !filteredData?.length ? (
+ ) : !proposals?.length ? (
{t("govActions.noResultsForTheSearch")}
@@ -81,7 +53,7 @@ export const DashboardGovernanceActionsVotedOn = ({
screenWidth < 420 ? "290px" : isMobile ? "324px" : "350px"
}, 1fr))`}
>
- {filteredData.map((item) => (
+ {proposals.map((item) => (
removeDuplicatedProposals(proposals),
- [proposals, voter?.isRegisteredAsDRep, isProposalsFetchingNextPage],
+ [proposals, isProposalsFetchingNextPage],
);
- // TODO: Filtering here is some kind of craziness. It should be done on the backend.
- const filteredProposals = useMemo(() => {
- const list = mappedData ?? [];
- if (!votes?.length) return list;
-
- const proposalsFromVotes = votes
- .flatMap((v) => v?.actions ?? [])
- .map((a) => a?.proposal)
- .filter(Boolean);
-
- const votedKeys = new Set(
- proposalsFromVotes
- .map((p) => ({
- id: p?.id ?? p?.id,
- tx: p?.txHash ?? p?.txHash,
- }))
- .filter(({ id, tx }) => Boolean(id && tx))
- .map(({ id, tx }) => `${id}:${tx}`),
- );
-
- if (votedKeys.size === 0) return list;
-
- return list.filter((p) => {
- const id = p?.id ?? p?.id;
- const tx = p?.txHash ?? p?.txHash;
- if (!id || !tx) return true;
- return !votedKeys.has(`${id}:${tx}`);
- });
- }, [mappedData, voter?.isRegisteredAsDRep, isProposalsFetchingNextPage]);
-
return (
<>
- {!filteredProposals ||
+ {!mappedProposals ||
isEnableLoading ||
- isProposalsLoading ||
- areDRepVotesLoading ||
- isFetchingVotes ? (
+ isProposalsLoading ? (
- ) : !filteredProposals?.length ? (
+ ) : !mappedProposals?.length ? (
{t("govActions.noResultsForTheSearch")}
@@ -125,7 +84,7 @@ export const GovernanceActionsToVote = ({
screenWidth < 420 ? "290px" : isMobile ? "324px" : "350px"
}, 1fr))`}
>
- {filteredProposals.map((item) => (
+ {mappedProposals.map((item) => (
{