Skip to content

Commit 2328c58

Browse files
sktbrdclaude
andcommitted
fix(poidh): invalidate bounty query after submitForVote/resolve/cancel — fixes stale Voting state
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 1776fa8 commit 2328c58

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

src/components/bounties/BountyDetailView.tsx

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import { useEffect, useState } from "react";
44
import Link from "next/link";
5-
import { useQuery } from "@tanstack/react-query";
5+
import { useQuery, useQueryClient } from "@tanstack/react-query";
66
import {
77
AlertCircle,
88
ArrowLeft,
@@ -183,6 +183,7 @@ export function BountyDetailView({ initialBounty, chainId, bountyId }: BountyDet
183183
});
184184

185185
const bounty = data?.bounty;
186+
const queryClient = useQueryClient();
186187

187188
const { ethPrice } = useEthPrice();
188189
const [joinAmount, setJoinAmount] = useState("0.001");
@@ -198,6 +199,27 @@ export function BountyDetailView({ initialBounty, chainId, bountyId }: BountyDet
198199
const resolveVoteHook = usePoidhResolveVote(chainId);
199200
const resetVotingHook = usePoidhResetVotingPeriod(chainId);
200201

202+
// Refresh bounty state after actions that change on-chain status
203+
const bountyQueryKey = ["poidh-bounty", chainId, bountyId];
204+
useEffect(() => {
205+
if (submitForVoteHook.isSuccess) {
206+
queryClient.invalidateQueries({ queryKey: bountyQueryKey });
207+
}
208+
// eslint-disable-next-line react-hooks/exhaustive-deps
209+
}, [submitForVoteHook.isSuccess]);
210+
useEffect(() => {
211+
if (resolveVoteHook.isSuccess) {
212+
queryClient.invalidateQueries({ queryKey: bountyQueryKey });
213+
}
214+
// eslint-disable-next-line react-hooks/exhaustive-deps
215+
}, [resolveVoteHook.isSuccess]);
216+
useEffect(() => {
217+
if (cancelHook.isSuccess) {
218+
queryClient.invalidateQueries({ queryKey: bountyQueryKey });
219+
}
220+
// eslint-disable-next-line react-hooks/exhaustive-deps
221+
}, [cancelHook.isSuccess]);
222+
201223
const deadlineTimestamp = bounty?.deadline ?? null;
202224
const countdown = useCountdown(deadlineTimestamp);
203225

0 commit comments

Comments
 (0)