diff --git a/src/gui/views/wallets/content.rs b/src/gui/views/wallets/content.rs index b4bc221..1f05ac4 100644 --- a/src/gui/views/wallets/content.rs +++ b/src/gui/views/wallets/content.rs @@ -454,19 +454,15 @@ impl WalletsContent { t!("wallets.checking"), repair_progress) } - } else if wallet.get_data().is_none() { + } else if wallet.syncing() { let info_progress = wallet.info_sync_progress(); - if info_progress != 100 { - if info_progress == 0 { - format!("{} {}", SPINNER, t!("wallets.loading")) - } else { + if info_progress == 100 || info_progress == 0 { + format!("{} {}", SPINNER, t!("wallets.loading")) + } else { format!("{} {}: {}%", SPINNER, t!("wallets.loading"), info_progress) - } - } else { - format!("{} {}", SPINNER, t!("wallets.tx_loading")) } } else { format!("{} {}", FOLDER_OPEN, t!("wallets.unlocked")) diff --git a/src/gui/views/wallets/wallet/content.rs b/src/gui/views/wallets/wallet/content.rs index c0a820a..fcef2fb 100644 --- a/src/gui/views/wallets/wallet/content.rs +++ b/src/gui/views/wallets/wallet/content.rs @@ -20,7 +20,7 @@ use grin_core::core::amount_to_hr_string; use crate::AppConfig; use crate::gui::Colors; -use crate::gui::icons::{ARROWS_CLOCKWISE, BRIDGE, CHAT_CIRCLE_TEXT, CHECK, CHECK_FAT, COPY, FOLDER_USER, GEAR_FINE, GRAPH, PACKAGE, PATH, POWER, SCAN, USERS_THREE}; +use crate::gui::icons::{ARROWS_CLOCKWISE, BRIDGE, CHAT_CIRCLE_TEXT, CHECK, CHECK_FAT, COPY, FOLDER_USER, GEAR_FINE, GRAPH, PACKAGE, PATH, POWER, SCAN, SPINNER, USERS_THREE}; use crate::gui::platform::PlatformCallbacks; use crate::gui::views::{CameraContent, Modal, Root, View}; use crate::gui::views::types::{ModalPosition, QrScanResult, TextEditOptions}; @@ -252,9 +252,33 @@ impl WalletContent { let acc_text = format!("{} {}", FOLDER_USER, acc_label); View::ellipsize_text(ui, acc_text, 15.0, Colors::text(false)); - // Show confirmed height. - let height_text = format!("{} {}", PACKAGE, data.info.last_confirmed_height); - View::animate_text(ui, height_text, 15.0, Colors::gray(), wallet.syncing()); + // Show confirmed height or sync progress. + let status_text = if !wallet.syncing() { + format!("{} {}", PACKAGE, data.info.last_confirmed_height) + } else { + let info_progress = wallet.info_sync_progress(); + if info_progress == 100 || info_progress == 0 { + format!("{} {}", SPINNER, t!("wallets.wallet_loading")) + } else { + if wallet.is_repairing() { + let rep_progress = wallet.repairing_progress(); + if rep_progress == 0 { + format!("{} {}", SPINNER, t!("wallets.wallet_checking")) + } else { + format!("{} {}: {}%", + SPINNER, + t!("wallets.wallet_checking"), + rep_progress) + } + } else { + format!("{} {}: {}%", + SPINNER, + t!("wallets.wallet_loading"), + info_progress) + } + } + }; + View::animate_text(ui, status_text, 15.0, Colors::gray(), wallet.syncing()); }) }); }); @@ -589,7 +613,7 @@ impl WalletContent { // Block navigation if wallet is repairing and integrated node is not launching // and if wallet is closing or syncing after opening when there is no data to show. (wallet.is_repairing() && (integrated_node_ready || !integrated_node) && !sync_error) - || wallet.is_closing() || (sync_after_opening && !integrated_node) + || wallet.is_closing() || sync_after_opening } /// Draw wallet sync progress content. diff --git a/src/wallet/wallet.rs b/src/wallet/wallet.rs index 0ee5d8c..b3af133 100644 --- a/src/wallet/wallet.rs +++ b/src/wallet/wallet.rs @@ -987,7 +987,7 @@ impl Wallet { } /// Check if wallet is repairing. - pub fn is_repairing(&self) -> bool { + pub fn is_repairing(&self) -> bool { self.repair_needed.load(Ordering::Relaxed) } @@ -1093,7 +1093,7 @@ fn start_sync(wallet: Wallet) -> Thread { } // Stop syncing if wallet was closed. - if !wallet.is_open() { + if !wallet.is_open() || wallet.is_closing() { on_thread_stop(wallet); return; } @@ -1119,7 +1119,7 @@ fn start_sync(wallet: Wallet) -> Thread { if wallet.is_repairing() { repair_wallet(&wallet); // Stop sync if wallet was closed. - if !wallet.is_open() { + if !wallet.is_open() || wallet.is_closing() { on_thread_stop(wallet); return; } @@ -1133,7 +1133,7 @@ fn start_sync(wallet: Wallet) -> Thread { let mut api_server_running = { wallet.foreign_api_server.read().is_some() }; - if !api_server_running && wallet.is_open() { + if !api_server_running && wallet.is_open() && !wallet.is_closing() { match start_api_server(&wallet) { Ok(api_server) => { let mut api_server_w = wallet.foreign_api_server.write(); @@ -1145,8 +1145,8 @@ fn start_sync(wallet: Wallet) -> Thread { } // Start Tor service if API server is running and wallet is open. - if wallet.auto_start_tor_listener() && wallet.is_open() && api_server_running && - !Tor::is_service_running(&wallet.identifier()) { + if wallet.auto_start_tor_listener() && wallet.is_open() && !wallet.is_closing() && + api_server_running && !Tor::is_service_running(&wallet.identifier()) { let r_foreign_api = wallet.foreign_api_server.read(); let api = r_foreign_api.as_ref().unwrap(); if let Ok(sec_key) = wallet.secret_key() { @@ -1159,7 +1159,7 @@ fn start_sync(wallet: Wallet) -> Thread { } // Stop sync if wallet was closed. - if !wallet.is_open() { + if !wallet.is_open() || wallet.is_closing() { on_thread_stop(wallet); return; } @@ -1214,7 +1214,8 @@ fn sync_wallet_data(wallet: &Wallet, from_node: bool) { config.min_confirmations ) { // Do not retrieve txs if wallet was closed or its first sync. - if !wallet.is_open() || !from_node && info.1.last_confirmed_height == 0 { + if !wallet.is_open() || wallet.is_closing() || + (!from_node && info.1.last_confirmed_height == 0) { return; }