Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

account.tsx improvements #3262

Merged
merged 4 commits into from
Mar 27, 2025
Merged

account.tsx improvements #3262

merged 4 commits into from
Mar 27, 2025

Conversation

benma
Copy link
Contributor

@benma benma commented Mar 27, 2025

No description provided.

@thisconnect thisconnect self-requested a review March 27, 2025 17:27
Copy link
Collaborator

@thisconnect thisconnect left a comment

Choose a reason for hiding this comment

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

very nice refactoring

tested LGTM

benma added 4 commits March 27, 2025 18:32
The account component has complicated logic trying to manage state
when `code` changes:

- reset everything to `undefined` when `code` changes
- check that callback responses still match the current code

This also prevents us from using the already existing hooks like
`useSync`, unless we modify them to accept `depdendencies` and `reset`
flags, which would make their use more complicated.

Conceptually it is much simpler to remount the account when `code`
changes, which automatically takes care of resetting the state and
removing subscriptions. Rendering performance is not visibly impacted,
as React still only applies the DOM diff.
Instead of manually dealing with loading/syncing it. Simpler code.
Now that we remount the whole component when `code` changes, there is
no need to check if the callback response matches the current code.
@benma benma merged commit 6bfab1d into BitBoxSwiss:master Mar 27, 2025
10 checks passed
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