Conversation
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 refactors how the application handles wallet changes within the main tab view. Instead of destroying and recreating the entire view hierarchy when the active wallet changes, the system now dynamically updates the relevant view model and its associated observable queries. This change aims to improve performance and provide a smoother user experience by avoiding costly view re-initializations. 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. Changelog
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.
Code Review
The pull request effectively addresses the dynamic updating of ObservableQuery by removing the .id() modifier from MainTabView and introducing an onChangeWallet function in MainTabViewModel. This change prevents the entire tab view from being recreated, leading to a smoother user experience. The wallet property in MainTabViewModel is correctly changed to var to allow modification, and TransactionsCountRequest's walletId is made public var for external updates. The use of onChange(of: _, _:) in MainTabView correctly triggers the wallet update logic. Overall, the changes are well-implemented and improve the application's responsiveness.
| VStack { | ||
| if let currentWallet = model.currentWallet { | ||
| MainTabView(model: .init(wallet: currentWallet)) | ||
| .id(currentWallet.walletId) |
There was a problem hiding this comment.
Removing the .id(currentWallet.walletId) modifier is a good change. It prevents SwiftUI from recreating the entire MainTabView hierarchy when the currentWallet changes, which can lead to better performance and a smoother user experience. Instead, the onChange modifier is now used within MainTabView to update the MainTabViewModel dynamically.
| func onChangeWallet(_ _: Wallet?, _ newWallet: Wallet?) { | ||
| guard let newWallet else { return } | ||
| wallet = newWallet | ||
| transactionsQuery.request.walletId = newWallet.walletId | ||
| } |
There was a problem hiding this comment.
| } | ||
| .toast(message: $model.isPresentingToastMessage) | ||
| .bindQuery(model.transactionsQuery) | ||
| .onChange(of: walletService.currentWallet, model.onChangeWallet) |
There was a problem hiding this comment.
Adding .onChange(of: walletService.currentWallet, model.onChangeWallet) is the correct way to observe changes in walletService.currentWallet and propagate them to the MainTabViewModel. This ensures that when the active wallet changes, the MainTabViewModel is notified and can update its internal state and queries accordingly.
Update ObservableQuery dynamically via onChangeWallet instead of recreating the entire tab view.