Skip to content

Commit 8c7e750

Browse files
authored
Merge pull request #3968 from IntersectMBO/develop
v2.0.32
2 parents 1485b42 + d3015fb commit 8c7e750

File tree

6 files changed

+39
-20
lines changed

6 files changed

+39
-20
lines changed

govtool/backend/src/VVA/API.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -296,22 +296,22 @@ getVotes (unHexText -> dRepId) selectedTypes sortMode mSearch = do
296296
CacheEnv {dRepGetVotesCache} <- asks vvaCache
297297
(votes, proposals) <- cacheRequest dRepGetVotesCache dRepId $ DRep.getVotes dRepId []
298298

299-
let voteMapByTxHash = Map.fromList $
300-
map (\vote -> (pack $ Prelude.takeWhile (/= '#') (unpack $ Types.voteGovActionId vote), vote)) votes
299+
let voteMapById = Map.fromList $
300+
map (\vote -> (Types.voteGovActionId vote, vote)) votes
301301

302302
processedProposals <- filter (isProposalSearchedFor mSearch) <$>
303303
mapSortAndFilterProposals selectedTypes sortMode proposals
304304

305-
return $
305+
return
306306
[ VoteResponse
307307
{ voteResponseVote = voteToResponse vote
308308
, voteResponseProposal = proposalResponse
309309
}
310310
| proposalResponse <- processedProposals
311-
, let txHash = unHexText (proposalResponseTxHash proposalResponse)
312-
, Just vote <- [Map.lookup txHash voteMapByTxHash]
311+
, let govActionId = unHexText (proposalResponseTxHash proposalResponse) <> "#" <> pack (show $ proposalResponseIndex proposalResponse)
312+
, Just vote <- [Map.lookup govActionId voteMapById]
313313
]
314-
314+
315315
drepInfo :: App m => HexText -> m DRepInfoResponse
316316
drepInfo (unHexText -> dRepId) = do
317317
CacheEnv {dRepInfoCache} <- asks vvaCache

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ export const DashboardGovernanceActionDetails = () => {
6060
);
6161

6262
useEffect(() => {
63-
if (data?.proposal && typeof isMetadataValid !== "boolean") {
63+
const extendedProposalIndex = extendedProposal ? extendedProposal.index : -1;
64+
if (data?.proposal && data?.proposal.index !== extendedProposalIndex) {
6465
setExtendedProposal(data.proposal);
6566
}
6667
}, [data?.proposal, isMetadataValid]);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export const DashboardGovernanceActions = () => {
9999
filters: stableFilters,
100100
sorting: stableSorting,
101101
searchPhrase: debouncedSearchText,
102-
enabled: true,
102+
enabled: voter?.isRegisteredAsDRep || voter?.isRegisteredAsSoleVoter,
103103
});
104104
const { data: votes, areDRepVotesLoading } = useGetDRepVotesQuery(
105105
queryFilters,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export const GovernanceActionsToVote = ({
4848
data={item.actions.slice(0, 6).map((action) => (
4949
<div
5050
className="keen-slider__slide"
51-
key={action.id}
51+
key={`${action.txHash}${action.index}`}
5252
style={{
5353
overflow: "visible",
5454
width: "auto",

govtool/frontend/src/hooks/queries/useGetProposalsQuery.ts

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,23 @@ export const useGetProposalsQuery = ({
3333
return allProposals.flatMap((proposal) => proposal.elements);
3434
};
3535

36-
const { data, isLoading } = useQuery(
37-
[QUERY_KEYS.useGetProposalsKey, filters, searchPhrase, sorting, dRepID],
38-
fetchProposals,
39-
{
40-
enabled,
41-
refetchOnWindowFocus: true,
42-
keepPreviousData: true,
43-
staleTime: 2000,
44-
},
45-
);
36+
const { data, isLoading } = useQuery(
37+
[
38+
QUERY_KEYS.useGetProposalsKey,
39+
filters,
40+
searchPhrase,
41+
sorting,
42+
dRepID,
43+
voter?.isRegisteredAsDRep,
44+
voter?.isRegisteredAsSoleVoter,
45+
],
46+
fetchProposals,
47+
{
48+
enabled,
49+
refetchOnWindowFocus: true,
50+
keepPreviousData: true,
51+
},
52+
);
4653

4754
const proposals = Object.values(groupByType(data) ?? []);
4855

govtool/frontend/src/pages/DRepDirectoryContent.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,24 @@ export const DRepDirectoryContent: FC<DRepDirectoryContentProps> = ({
5050
}) => {
5151
const { dRepID: myDRepId, pendingTransaction, stakeKey } = useCardano();
5252
const { t } = useTranslation();
53-
const { debouncedSearchText, ...dataActionsBarProps } = useDataActionsBar();
53+
54+
const {
55+
searchText,
56+
debouncedSearchText,
57+
setSearchText,
58+
...dataActionsBarProps
59+
} = useDataActionsBar();
60+
5461
const { chosenFilters, chosenSorting, setChosenFilters, setChosenSorting } =
5562
dataActionsBarProps;
5663

5764
const [inProgressDelegationDRepData, setInProgressDelegationDRepData] =
5865
useState<DRepData | undefined>(undefined);
5966

67+
// Set initial filters and sort
6068
useEffect(() => {
6169
setChosenFilters([DRepStatus.Active]);
70+
setSearchText(""); // <--- Clear the search field on mount
6271
}, []);
6372

6473
useEffect(() => {
@@ -198,6 +207,8 @@ export const DRepDirectoryContent: FC<DRepDirectoryContentProps> = ({
198207
</Typography>
199208
<DataActionsBar
200209
{...dataActionsBarProps}
210+
searchText={searchText}
211+
setSearchText={setSearchText}
201212
filterOptions={DREP_DIRECTORY_FILTERS}
202213
filtersTitle={t("dRepDirectory.filterTitle")}
203214
sortOptions={DREP_DIRECTORY_SORTING}

0 commit comments

Comments
 (0)