Skip to content

feat: use cache-and-network fetch policy for treasury votes#570

Open
rickstaa wants to merge 2 commits intofeat/ens-cache-improvementsfrom
feat/apollo-cache-and-network-votes
Open

feat: use cache-and-network fetch policy for treasury votes#570
rickstaa wants to merge 2 commits intofeat/ens-cache-improvementsfrom
feat/apollo-cache-and-network-votes

Conversation

@rickstaa
Copy link
Member

@rickstaa rickstaa commented Mar 3, 2026

Summary

  • Adds fetchPolicy: "cache-and-network" to both useTreasuryVotesQuery and useTreasuryVoteEventsQuery
  • Apollo serves cached vote data instantly on navigation (no loading spinner on revisit) and silently refetches in the background to pick up new votes

Stack

This is part of a stacked PR chain:

  1. #561 feat/improve-treasury-votes-caching-behavior — ENS caching
  2. #569 feat/ens-cache-improvements — remove redundant localEnsCache + add TTL
  3. This PR feat/apollo-cache-and-network-votes — Apollo fetch policy for vote data

Test plan

  • Navigate to a treasury proposal — votes should load normally
  • Navigate away and back — vote table should render instantly from cache (no spinner), then update if new votes arrived

🤖 Generated with Claude Code

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 <noreply@anthropic.com>
@rickstaa rickstaa requested a review from ECWireless as a code owner March 3, 2026 09:35
@vercel
Copy link
Contributor

vercel bot commented Mar 3, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
explorer-arbitrum-one Ready Ready Preview, Comment Mar 3, 2026 2:10pm

Request Review

Copy link
Contributor

@vercel vercel bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional Suggestions:

  1. Missing return statement in useEffect causes decorateVotes to execute when data is not yet loaded
  1. Error message displayed instead of cached votes when background refetch fails with cache-and-network fetch policy

Fix on Vercel

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 <noreply@anthropic.com>
@ECWireless
Copy link
Collaborator

@rickstaa should this be closed given #572 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants