Skip to content

frontend: re-fetch btcdirectinfo in case account is not synced#4105

Closed
thisconnect wants to merge 1 commit into
BitBoxSwiss:release-v4.51.0-rc1from
thisconnect:frontend-wait-for-account
Closed

frontend: re-fetch btcdirectinfo in case account is not synced#4105
thisconnect wants to merge 1 commit into
BitBoxSwiss:release-v4.51.0-rc1from
thisconnect:frontend-wait-for-account

Conversation

@thisconnect
Copy link
Copy Markdown
Collaborator

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:

  • updating the Changelog
  • writing unit tests
  • checking if your changes affect other coins or tokens in unintended ways
  • testing on multiple environments (Qt, Android, ...)
  • having an AI review your changes

Fixed BTCDirect loading forever if the account is not fully synced.
@benma
Copy link
Copy Markdown
Contributor

benma commented May 5, 2026

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 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".

Comment on lines +53 to +54
const fetchBTCDirectInfo = useCallback(async () => {
setBtcdirectInfo(await getBTCDirectInfo(action, code));
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

@thisconnect
Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 5, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 5, 2026

📝 Walkthrough

Walkthrough

The BTCDirect component's data-fetching mechanism was refactored from using the useLoad hook to an explicit combination of useState, useCallback, and useEffect. The BTCDirect info is now stored in a state variable and fetched via a memoized callback function. An additional effect was introduced to re-fetch the BTCDirect information when the account sync completes, utilizing the syncdone callback for coordination. Error handling and downstream message processing now depend on the new stateful btcdirectInfo value.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.

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.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between a629742 and d0fd59f.

📒 Files selected for processing (1)
  • frontends/web/src/routes/market/btcdirect.tsx

Comment thread frontends/web/src/routes/market/btcdirect.tsx
@thisconnect
Copy link
Copy Markdown
Collaborator Author

Closing in favor of #4121

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