Repository navigation
Conversation
- Create inactivityStore to track user interactions (mouse, keyboard, touch, scroll) - Stop API polling when tab is inactive for 5+ minutes - Add inactivity check to amountsStore and tokensStore - Prevents unnecessary background balance/token fetches - Resumes immediately on user interaction
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Server evaluation can crash, and skipped token refreshes do not resume immediately.
2 open findings
What changed in this PR
Adds inactivity-aware polling to reduce background wallet API calls.
Changes:
- Tracks user activity with a configurable timeout.
- Pauses token and balance polling when unfocused or inactive.
- Adds CDN-specific balance caching headers.
| File | Description |
|---|---|
inactivityStore.ts |
Tracks interactions and inactivity state. |
amountsStore.ts |
Pauses balance polling during inactivity. |
tokensStore.ts |
Pauses hourly token polling. |
route.ts |
Configures CDN balance caching. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: sirpy <hadarr@gmail.com>
Co-authored-by: sirpy <671095+sirpy@users.noreply.github.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
Implements inactivity detection to prevent unnecessary background API calls when the wallet tab is left open but inactive.
Changes
amountsStoreandtokensStoreto respect both window focus and inactivity stateProblem Solved
Previously, the wallet would continue making background API calls (balance checks for Bitcoin/Doge) even when left idle in a tab, consuming bandwidth and rate limits.
Configuration
Inactivity timeout is configurable via
inactivityStore.inactivityTimeoutMs(currently 5 minutes).Files Changed
src/hooks/useTokenBalances/stores/inactivityStore.ts(new)src/hooks/useTokenBalances/stores/amountsStore.tssrc/hooks/useTokenBalances/stores/tokensStore.tssrc/app/api/chains/[family]/addresses/[address]/balance/route.ts