-
Notifications
You must be signed in to change notification settings - Fork 58
Fix wallet setup order in onboarding view models #1544
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
Conversation
Moved the call to set the current wallet after dismissing the onboarding view in both CreateWalletModel and ImportWalletViewModel. This ensures the wallet is set after the UI is dismissed, potentially preventing race conditions or UI inconsistencies.
Summary of ChangesHello @DRadmir, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a potential issue where the current wallet might be set before the onboarding view is fully dismissed, leading to race conditions or UI inconsistencies. By reordering the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request refactors the wallet setup completion logic in CreateWalletModel and ImportWalletViewModel. By moving the call to walletService.setCurrent(wallet:) to after the dismiss() call, it correctly ensures that the UI dismissal is initiated before the current wallet state is updated. This is a good practice to prevent potential race conditions and UI inconsistencies that could arise from updating state on a view that is about to be dismissed. The changes are clear, concise, and improve the robustness of the onboarding flow. I've added a minor suggestion regarding the throws keyword on the setCurrent method for future consideration.
| func setupWalletComplete(wallet: Wallet) async throws { | ||
| try await walletService.setCurrent(wallet: wallet) | ||
| dismiss() | ||
| try await walletService.setCurrent(wallet: wallet) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While the reordering is correct, I noticed that walletService.setCurrent(wallet:) is marked as throws, which necessitates the use of try here. Looking at the implementation in WalletService.swift, the function doesn't seem to have any throwing paths. It might be beneficial to remove throws from the function signature to avoid unnecessary try keywords at call sites. This could be addressed in a separate refactoring effort.
| func setupWalletComplete(wallet: Wallet) async throws { | ||
| try await walletService.setCurrent(wallet: wallet) | ||
| dismiss() | ||
| try await walletService.setCurrent(wallet: wallet) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to the other view model, the reordering is a good improvement. I also noticed here that walletService.setCurrent(wallet:) is marked as throws, but its implementation doesn't appear to throw. For consistency and code clarity, it might be worth considering removing throws from its signature in a future change, which would allow removing try from this call.
Moved the call to set the current wallet after dismissing the onboarding view in both CreateWalletModel and ImportWalletViewModel. This ensures the wallet is set after the UI is dismissed, potentially preventing race conditions or UI inconsistencies.