Skip to content

Commit

Permalink
Validate and fix wallet name on Done
Browse files Browse the repository at this point in the history
  • Loading branch information
praveenperera committed Dec 1, 2024
1 parent 981073d commit 713bb83
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
6 changes: 0 additions & 6 deletions ios/Cove/Flows/SelectedWalletFlow/SelectedWalletScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,6 @@ struct SelectedWalletScreen: View {
let _ = try? await model.rust.forceUpdateHeight()
}
.onAppear {
if metadata.name.isEmpty {
model.dispatch(
action: .updateName(
metadata.masterFingerprint?.asUppercase() ?? "Unnamed Wallet"))
}

UIRefreshControl.appearance().tintColor = UIColor.white
}
.scrollIndicators(.hidden)
Expand Down
16 changes: 15 additions & 1 deletion rust/src/view_model/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,21 @@ impl RustWalletViewModel {
Ok(())
}

#[uniffi::method]
pub fn validate_metadata(&self) {
if self.metadata.read().name.trim().is_empty() {
let name = self
.metadata
.read()
.master_fingerprint
.as_ref()
.map(|f| f.as_uppercase())
.unwrap_or_else(|| "Unnamed Wallet".to_string());

self.dispatch(WalletViewModelAction::UpdateName(name));
}
}

#[uniffi::method]
pub async fn start_wallet_scan(&self) -> Result<(), Error> {
debug!("start_wallet_scan: {}", self.id);
Expand Down Expand Up @@ -811,7 +826,6 @@ impl RustWalletViewModel {
#[uniffi::method]
pub fn dispatch(&self, action: WalletViewModelAction) {
match action {
WalletViewModelAction::UpdateName(name) if name.is_empty() => {}
WalletViewModelAction::UpdateName(name) => {
let mut metadata = self.metadata.write();
metadata.name = name;
Expand Down

0 comments on commit 713bb83

Please sign in to comment.