From 2e9124451615d194c199ca668108878c0f5db3dd Mon Sep 17 00:00:00 2001 From: bosko-m <88723596+bosko-m@users.noreply.github.com> Date: Tue, 29 Jul 2025 18:07:43 +0200 Subject: [PATCH 1/2] Update useGetProposalsQuery.ts - 3978 - voterReady logic added Signed-off-by: bosko-m <88723596+bosko-m@users.noreply.github.com> --- .../src/hooks/queries/useGetProposalsQuery.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/govtool/frontend/src/hooks/queries/useGetProposalsQuery.ts b/govtool/frontend/src/hooks/queries/useGetProposalsQuery.ts index 27f349615..b0188e30c 100644 --- a/govtool/frontend/src/hooks/queries/useGetProposalsQuery.ts +++ b/govtool/frontend/src/hooks/queries/useGetProposalsQuery.ts @@ -10,11 +10,19 @@ export const useGetProposalsQuery = ({ filters = [], searchPhrase, sorting, - enabled, + enabled = true, }: GetProposalsArguments) => { const { dRepID } = useCardano(); const { voter } = useGetVoterInfo(); +// Determine if voter is ready to be used in the query +const voterReady = + !!dRepID && (voter?.isRegisteredAsDRep || voter?.isRegisteredAsSoleVoter); + +// Only run the query if enabled externally and voter info is ready +const shouldFetch = enabled && voterReady; + + const fetchProposals = async (): Promise => { const allProposals = await Promise.all( filters.map((filter) => @@ -45,7 +53,7 @@ export const useGetProposalsQuery = ({ ], fetchProposals, { - enabled, + enabled: shouldFetch, refetchOnWindowFocus: true, keepPreviousData: true, }, From 5c8059e1b6a6548fa8b9741b65306f0a83b2e6d0 Mon Sep 17 00:00:00 2001 From: Aaron Boyle Date: Tue, 29 Jul 2025 17:55:12 +0100 Subject: [PATCH 2/2] update to corrects empty line linting error --- govtool/frontend/src/hooks/queries/useGetProposalsQuery.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/govtool/frontend/src/hooks/queries/useGetProposalsQuery.ts b/govtool/frontend/src/hooks/queries/useGetProposalsQuery.ts index b0188e30c..da62db474 100644 --- a/govtool/frontend/src/hooks/queries/useGetProposalsQuery.ts +++ b/govtool/frontend/src/hooks/queries/useGetProposalsQuery.ts @@ -22,7 +22,6 @@ const voterReady = // Only run the query if enabled externally and voter info is ready const shouldFetch = enabled && voterReady; - const fetchProposals = async (): Promise => { const allProposals = await Promise.all( filters.map((filter) =>