Skip to content

Use balances interval#235

Closed
Adeyemi-cmd wants to merge 2 commits into
TrusTrove:mainfrom
Adeyemi-cmd:useBalances_interval
Closed

Use balances interval#235
Adeyemi-cmd wants to merge 2 commits into
TrusTrove:mainfrom
Adeyemi-cmd:useBalances_interval

Conversation

@Adeyemi-cmd

Copy link
Copy Markdown
Contributor

Close #142

PR Description

Summary

Replaces the manual setInterval(fetchBalances, 30000) in useBalances with @tanstack/react-query's useQuery to properly pause polling when the tab is backgrounded.

Problem

setInterval(fetchBalances, 30000) runs regardless of page visibility. The callback fires even when the tab is in the background, wasting network requests and battery.

Solution

  • Use useQuery with refetchInterval: 30000 and refetchIntervalInBackground: false (default) — polling auto-pauses when the tab is hidden and resumes when visible.
  • Use enabled: !!address && connected to skip all requests when the wallet is disconnected.
  • Extract fetchBalancesFromHorizon as a standalone async function.
  • Update tests to mock @tanstack/react-query (consistent with other hooks in the codebase).

Acceptance Criteria

  • Polling pauses when tab is backgrounded
  • Polling resumes when tab becomes visible
  • No unnecessary network requests on disconnected state
  • All existing tests pass

@vercel

vercel Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

@Adeyemi-cmd is attempting to deploy a commit to the K1NGD4VID Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Jun 29, 2026

Copy link
Copy Markdown

@Adeyemi-cmd Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@K1NGD4VID

Copy link
Copy Markdown
Contributor

Resolve Merge confict @Adeyemi-cmd

@K1NGD4VID

Copy link
Copy Markdown
Contributor

Resolve Merge Conflict @Adeyemi-cmd

@K1NGD4VID K1NGD4VID closed this Jul 6, 2026
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.

useBalances interval polling continues when tab is backgrounded

2 participants