Skip to content

Show alert on wallet import#1742

Merged
DRadmir merged 1 commit intomainfrom
fix/import-wallet-error-alert
Feb 26, 2026
Merged

Show alert on wallet import#1742
DRadmir merged 1 commit intomainfrom
fix/import-wallet-error-alert

Conversation

@DRadmir
Copy link
Contributor

@DRadmir DRadmir commented Feb 26, 2026

Move import logic (loadOrCreateWallet, acceptTerms, setCurrent) from ImportWalletViewModel into ImportWalletSceneViewModel where errors are caught and displayed to the user via alert with button state reset.

Simulator Screenshot - iPhone 17 Pro Max - 2026-02-26 at 15 54 01

@DRadmir DRadmir self-assigned this Feb 26, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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 significantly refactors the wallet import flow by relocating critical business logic and error handling to the ImportWalletSceneViewModel. This change centralizes the responsibility for managing the import process, including displaying user-facing alerts for any encountered errors and resetting UI elements. The ImportWalletViewModel has been streamlined, and the navigation stack's callbacks are simplified to directly receive the imported wallet.

Highlights

  • Refactored Wallet Import Logic: The core logic for loading, creating, accepting terms, and setting the current wallet has been moved from ImportWalletViewModel to ImportWalletSceneViewModel.
  • Centralized Error Handling: Wallet import operations within ImportWalletSceneViewModel now catch and display errors to the user via alerts, improving user feedback.
  • Improved UI State Management: Button states are reset upon completion or error during the import process, ensuring a responsive user interface.
  • Streamlined Navigation Callbacks: The ImportWalletNavigationStack now receives a Wallet object directly upon successful import, simplifying its onImportComplete handler.

🧠 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
  • Features/Onboarding/Sources/Navigation/ImportWalletNavigationStack.swift
    • Removed the Localization import.
    • Updated the onImportComplete function to accept a Wallet object directly instead of WalletImportData.
    • Simplified the onSetupWalletComplete function to directly call the onComplete handler from the model.
    • Removed Task blocks and error handling for wallet import and setup completion, delegating these concerns to the ViewModel.
  • Features/Onboarding/Sources/ViewModels/ImportWalletSceneViewModel.swift
    • Modified the onComplete closure type to pass a Wallet object.
    • Updated internal importWallet calls to be async throws.
    • Integrated the walletService.loadOrCreateWallet, walletService.acceptTerms, and walletService.setCurrent logic directly into the private func importWallet method, making it async throws.
    • Added buttonState = .normal to reset the UI state after a successful import.
  • Features/Onboarding/Sources/ViewModels/ImportWalletViewModel.swift
    • Removed the dismiss() function.
    • Removed the importWallet(data:) function, as its logic was moved.
    • Removed the setupWalletComplete() function, as its logic was moved or simplified.
Activity
  • The author, DRadmir, has provided a screenshot demonstrating the alert functionality on wallet import, indicating visual testing and confirmation of the new error display.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request successfully refactors the wallet import logic by moving it from ImportWalletViewModel to ImportWalletSceneViewModel. This centralizes the import process, allowing for better error handling and alert display, as well as resetting the button state upon completion or error. The changes align well with the stated goal of showing alerts on wallet import.


import SwiftUI
import Primitives
import Localization
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The Localization import was removed from this file. While this is a good cleanup if no longer needed, please ensure that no localized strings or components that rely on Localization are still being used indirectly by ImportWalletNavigationStack or its subviews. If they are, the import should be retained, or the localization moved to the respective view models.

@DRadmir DRadmir force-pushed the fix/import-wallet-error-alert branch from d62d362 to 4c57277 Compare February 26, 2026 11:32
@DRadmir DRadmir force-pushed the fix/import-wallet-error-alert branch from 4c57277 to af0100c Compare February 26, 2026 11:33
@DRadmir DRadmir merged commit 929af9d into main Feb 26, 2026
1 of 2 checks passed
@DRadmir DRadmir deleted the fix/import-wallet-error-alert branch February 26, 2026 11:56
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