Skip to content

Commit

Permalink
Refetch upvoters after tx
Browse files Browse the repository at this point in the history
  • Loading branch information
jmrossy committed Mar 8, 2024
1 parent 4688544 commit 79fc95c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/features/governance/UpvoteForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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<UpvoteFormValues>({
createTxPlan: (v) => getUpvoteTxPlan(v, queue || [], votingPower || 0n),
onStepSuccess: () => refetchUpvoters(),
onPlanSuccess: (v, r) =>
onConfirmed({
message: 'Upvote successful',
Expand Down
3 changes: 2 additions & 1 deletion src/features/governance/hooks/useProposalUpvoters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -27,6 +27,7 @@ export function useProposalUpvoters(id?: number) {
isLoading,
isError,
upvoters: data || undefined,
refetch,
};
}

Expand Down

0 comments on commit 79fc95c

Please sign in to comment.