frontend: re-fetch btcdirectinfo in case account is not synced#4105
frontend: re-fetch btcdirectinfo in case account is not synced#4105thisconnect wants to merge 1 commit into
Conversation
Fixed BTCDirect loading forever if the account is not fully synced.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d0fd59f839
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const fetchBTCDirectInfo = useCallback(async () => { | ||
| setBtcdirectInfo(await getBTCDirectInfo(action, code)); |
There was a problem hiding this comment.
Ignore stale BTCDirect info responses when refetching
fetchBTCDirectInfo writes every response directly into state, but this effect can create overlapping requests (the initial fetch plus the syncdone-triggered fetch). If the older request resolves last, it can overwrite a newer successful payload with stale data (for example, switching back to success: false after sync), which can leave the widget in the wrong state until another sync event occurs. Track request generation (or cancel/ignore outdated requests) before calling setBtcdirectInfo to ensure only the latest response is applied.
Useful? React with 👍 / 👎.
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
📝 WalkthroughWalkthroughThe BTCDirect component's data-fetching mechanism was refactored from using the ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@frontends/web/src/routes/market/btcdirect.tsx`:
- Around line 53-60: fetchBTCDirectInfo can leave stale btcdirectInfo visible
and allow out‑of‑order responses to overwrite fresh data; fix by making
fetchBTCDirectInfo first set btcdirectInfo to undefined (loading state) and add
a response-order guard: add a request counter/ref (e.g., useRef
currentRequestId) that you increment before calling getBTCDirectInfo(action,
code) and capture locally, then only call setBtcdirectInfo with the response if
the captured request id matches the latest ref; keep the guard logic inside
fetchBTCDirectInfo and keep useEffect/syncdone usage as-is.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 3bee655a-31c3-4c26-bc13-99dade0bb8c8
📒 Files selected for processing (1)
frontends/web/src/routes/market/btcdirect.tsx
|
Closing in favor of #4121 |
Fixed BTCDirect loading forever if the account is not fully synced.
Before asking for reviews, here is a check list of the most common things you might need to consider: