From a10956834396ca7e0371dcd41625a590bdd4a97b Mon Sep 17 00:00:00 2001 From: Rick Staa Date: Tue, 3 Mar 2026 10:34:50 +0100 Subject: [PATCH 1/2] feat: use cache-and-network fetch policy for treasury vote queries Serve cached vote data instantly on navigation and silently refetch in the background, eliminating unnecessary loading spinners on revisit. Co-Authored-By: Claude Opus 4.6 --- components/Treasury/TreasuryVoteTable/index.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/Treasury/TreasuryVoteTable/index.tsx b/components/Treasury/TreasuryVoteTable/index.tsx index 85719b2c..52e103b4 100644 --- a/components/Treasury/TreasuryVoteTable/index.tsx +++ b/components/Treasury/TreasuryVoteTable/index.tsx @@ -84,6 +84,7 @@ const useVotes = (proposalId: string) => { proposal: proposalId, }, }, + fetchPolicy: "cache-and-network", }); const { @@ -97,6 +98,7 @@ const useVotes = (proposalId: string) => { proposal: proposalId, }, }, + fetchPolicy: "cache-and-network", }); const [votes, setVotes] = useState([]); From 63b948a3877e04d9f6ec9497b9097a8cbaaea182 Mon Sep 17 00:00:00 2001 From: Rick Staa Date: Tue, 3 Mar 2026 15:07:14 +0100 Subject: [PATCH 2/2] fix: prevent stale execution and preserve cached votes on refetch error Add missing return statement in useEffect guard so decorateVotes does not execute when data is not yet loaded. Also only show the error state when there are no cached votes, so a failed background refetch with cache-and-network does not replace already-displayed results. Co-Authored-By: Claude Opus 4.6 --- components/Treasury/TreasuryVoteTable/index.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/Treasury/TreasuryVoteTable/index.tsx b/components/Treasury/TreasuryVoteTable/index.tsx index 52e103b4..e1f20008 100644 --- a/components/Treasury/TreasuryVoteTable/index.tsx +++ b/components/Treasury/TreasuryVoteTable/index.tsx @@ -109,7 +109,9 @@ const useVotes = (proposalId: string) => { !treasuryVoteEventsData?.treasuryVoteEvents ) { setVotes([]); + return; } + const decorateVotes = async () => { setVotesLoading(true); const uniqueVoters = Array.from( @@ -206,7 +208,7 @@ const Index: React.FC = ({ proposalId }) => { ); } - if (error) + if (error && !votes.length) return ( Error loading votes: {error.message}