From 79fc95c5a45f9dd1b1fa50a0f82d87ab78b60059 Mon Sep 17 00:00:00 2001 From: J M Rossy Date: Fri, 8 Mar 2024 18:24:41 -0500 Subject: [PATCH] Refetch upvoters after tx --- src/features/governance/UpvoteForm.tsx | 3 +++ src/features/governance/hooks/useProposalUpvoters.ts | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/features/governance/UpvoteForm.tsx b/src/features/governance/UpvoteForm.tsx index 3ceef91..da76c80 100644 --- a/src/features/governance/UpvoteForm.tsx +++ b/src/features/governance/UpvoteForm.tsx @@ -2,6 +2,7 @@ import { Form, Formik, FormikErrors } from 'formik'; import { FormSubmitButton } from 'src/components/buttons/FormSubmitButton'; import { ProposalFormDetails } from 'src/features/governance/components/ProposalFormDetails'; import { useProposalQueue } from 'src/features/governance/hooks/useProposalQueue'; +import { useProposalUpvoters } from 'src/features/governance/hooks/useProposalUpvoters'; import { useGovernanceVotingPower, useIsGovernanceUpVoting, @@ -29,9 +30,11 @@ export function UpvoteForm({ const { queue } = useProposalQueue(); const { isUpvoting } = useIsGovernanceUpVoting(address); const { votingPower } = useGovernanceVotingPower(address); + const { refetch: refetchUpvoters } = useProposalUpvoters(); const { getNextTx, onTxSuccess } = useTransactionPlan({ createTxPlan: (v) => getUpvoteTxPlan(v, queue || [], votingPower || 0n), + onStepSuccess: () => refetchUpvoters(), onPlanSuccess: (v, r) => onConfirmed({ message: 'Upvote successful', diff --git a/src/features/governance/hooks/useProposalUpvoters.ts b/src/features/governance/hooks/useProposalUpvoters.ts index 16c4cd8..f67044e 100644 --- a/src/features/governance/hooks/useProposalUpvoters.ts +++ b/src/features/governance/hooks/useProposalUpvoters.ts @@ -10,7 +10,7 @@ import { objFilter } from 'src/utils/objects'; import { decodeEventLog, encodeEventTopics } from 'viem'; export function useProposalUpvoters(id?: number) { - const { isLoading, isError, error, data } = useQuery({ + const { isLoading, isError, error, data, refetch } = useQuery({ queryKey: ['useProposalUpvoters', id], queryFn: () => { if (!id) return null; @@ -27,6 +27,7 @@ export function useProposalUpvoters(id?: number) { isLoading, isError, upvoters: data || undefined, + refetch, }; }