@@ -4,9 +4,7 @@ import { Typography } from "@atoms";
44import { useCardano , useDataActionsBar } from "@context" ;
55import {
66 useFetchNextPageDetector ,
7- useGetDRepVotesQuery ,
87 useGetProposalsInfiniteQuery ,
9- useGetVoterInfo ,
108 useSaveScrollPosition ,
119 useScreenDimension ,
1210 useTranslation ,
@@ -26,7 +24,6 @@ export const GovernanceActionsToVote = ({
2624 const { isMobile, screenWidth } = useScreenDimension ( ) ;
2725 const { debouncedSearchText, ...dataActionsBarProps } = useDataActionsBar ( ) ;
2826 const { chosenSorting, chosenFilters } = dataActionsBarProps ;
29- const { voter } = useGetVoterInfo ( ) ;
3027 const { t } = useTranslation ( ) ;
3128
3229 const {
@@ -49,59 +46,21 @@ export const GovernanceActionsToVote = ({
4946 proposalsHaveNextPage ,
5047 ) ;
5148
52- const {
53- data : votes ,
54- areDRepVotesLoading,
55- isFetching : isFetchingVotes ,
56- } = useGetDRepVotesQuery ( chosenFilters , chosenSorting , debouncedSearchText ) ;
57-
5849 const saveScrollPosition = useSaveScrollPosition (
5950 isProposalsLoading ,
6051 isProposalsFetching ,
6152 ) ;
6253
63- const mappedData = useMemo (
54+ const mappedProposals = useMemo (
6455 ( ) => removeDuplicatedProposals ( proposals ) ,
65- [ proposals , voter ?. isRegisteredAsDRep , isProposalsFetchingNextPage ] ,
56+ [ proposals , isProposalsFetchingNextPage ] ,
6657 ) ;
6758
68- // TODO: Filtering here is some kind of craziness. It should be done on the backend.
69- const filteredProposals = useMemo ( ( ) => {
70- const list = mappedData ?? [ ] ;
71- if ( ! votes ?. length ) return list ;
72-
73- const proposalsFromVotes = votes
74- . flatMap ( ( v ) => v ?. actions ?? [ ] )
75- . map ( ( a ) => a ?. proposal )
76- . filter ( Boolean ) ;
77-
78- const votedKeys = new Set (
79- proposalsFromVotes
80- . map ( ( p ) => ( {
81- id : p ?. id ?? p ?. id ,
82- tx : p ?. txHash ?? p ?. txHash ,
83- } ) )
84- . filter ( ( { id, tx } ) => Boolean ( id && tx ) )
85- . map ( ( { id, tx } ) => `${ id } :${ tx } ` ) ,
86- ) ;
87-
88- if ( votedKeys . size === 0 ) return list ;
89-
90- return list . filter ( ( p ) => {
91- const id = p ?. id ?? p ?. id ;
92- const tx = p ?. txHash ?? p ?. txHash ;
93- if ( ! id || ! tx ) return true ;
94- return ! votedKeys . has ( `${ id } :${ tx } ` ) ;
95- } ) ;
96- } , [ mappedData , voter ?. isRegisteredAsDRep , isProposalsFetchingNextPage ] ) ;
97-
9859 return (
9960 < >
100- { ! filteredProposals ||
61+ { ! mappedProposals ||
10162 isEnableLoading ||
102- isProposalsLoading ||
103- areDRepVotesLoading ||
104- isFetchingVotes ? (
63+ isProposalsLoading ? (
10564 < Box
10665 sx = { {
10766 alignItems : "center" ,
@@ -113,7 +72,7 @@ export const GovernanceActionsToVote = ({
11372 >
11473 < CircularProgress />
11574 </ Box >
116- ) : ! filteredProposals ?. length ? (
75+ ) : ! mappedProposals ?. length ? (
11776 < Typography fontWeight = { 300 } sx = { { py : 4 } } >
11877 { t ( "govActions.noResultsForTheSearch" ) }
11978 </ Typography >
@@ -125,7 +84,7 @@ export const GovernanceActionsToVote = ({
12584 screenWidth < 420 ? "290px" : isMobile ? "324px" : "350px"
12685 } , 1fr))`}
12786 >
128- { filteredProposals . map ( ( item ) => (
87+ { mappedProposals . map ( ( item ) => (
12988 < Box pb = { 4.25 } key = { item . txHash + item . index } >
13089 < ValidatedGovernanceActionCard
13190 { ...item }
0 commit comments