wallet: sync status text, closing check at sync thread

This commit is contained in:
ardocrat 2024-06-04 12:17:01 +03:00
parent 610c96a8bd
commit a9e59f3a22
3 changed files with 42 additions and 21 deletions

View file

@ -454,10 +454,9 @@ impl WalletsContent {
t!("wallets.checking"), t!("wallets.checking"),
repair_progress) repair_progress)
} }
} else if wallet.get_data().is_none() { } else if wallet.syncing() {
let info_progress = wallet.info_sync_progress(); let info_progress = wallet.info_sync_progress();
if info_progress != 100 { if info_progress == 100 || info_progress == 0 {
if info_progress == 0 {
format!("{} {}", SPINNER, t!("wallets.loading")) format!("{} {}", SPINNER, t!("wallets.loading"))
} else { } else {
format!("{} {}: {}%", format!("{} {}: {}%",
@ -465,9 +464,6 @@ impl WalletsContent {
t!("wallets.loading"), t!("wallets.loading"),
info_progress) info_progress)
} }
} else {
format!("{} {}", SPINNER, t!("wallets.tx_loading"))
}
} else { } else {
format!("{} {}", FOLDER_OPEN, t!("wallets.unlocked")) format!("{} {}", FOLDER_OPEN, t!("wallets.unlocked"))
} }

View file

@ -20,7 +20,7 @@ use grin_core::core::amount_to_hr_string;
use crate::AppConfig; use crate::AppConfig;
use crate::gui::Colors; 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::platform::PlatformCallbacks;
use crate::gui::views::{CameraContent, Modal, Root, View}; use crate::gui::views::{CameraContent, Modal, Root, View};
use crate::gui::views::types::{ModalPosition, QrScanResult, TextEditOptions}; use crate::gui::views::types::{ModalPosition, QrScanResult, TextEditOptions};
@ -252,9 +252,33 @@ impl WalletContent {
let acc_text = format!("{} {}", FOLDER_USER, acc_label); let acc_text = format!("{} {}", FOLDER_USER, acc_label);
View::ellipsize_text(ui, acc_text, 15.0, Colors::text(false)); View::ellipsize_text(ui, acc_text, 15.0, Colors::text(false));
// Show confirmed height. // Show confirmed height or sync progress.
let height_text = format!("{} {}", PACKAGE, data.info.last_confirmed_height); let status_text = if !wallet.syncing() {
View::animate_text(ui, height_text, 15.0, Colors::gray(), 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 // 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. // 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_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. /// Draw wallet sync progress content.

View file

@ -1093,7 +1093,7 @@ fn start_sync(wallet: Wallet) -> Thread {
} }
// Stop syncing if wallet was closed. // Stop syncing if wallet was closed.
if !wallet.is_open() { if !wallet.is_open() || wallet.is_closing() {
on_thread_stop(wallet); on_thread_stop(wallet);
return; return;
} }
@ -1119,7 +1119,7 @@ fn start_sync(wallet: Wallet) -> Thread {
if wallet.is_repairing() { if wallet.is_repairing() {
repair_wallet(&wallet); repair_wallet(&wallet);
// Stop sync if wallet was closed. // Stop sync if wallet was closed.
if !wallet.is_open() { if !wallet.is_open() || wallet.is_closing() {
on_thread_stop(wallet); on_thread_stop(wallet);
return; return;
} }
@ -1133,7 +1133,7 @@ fn start_sync(wallet: Wallet) -> Thread {
let mut api_server_running = { let mut api_server_running = {
wallet.foreign_api_server.read().is_some() 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) { match start_api_server(&wallet) {
Ok(api_server) => { Ok(api_server) => {
let mut api_server_w = wallet.foreign_api_server.write(); 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. // Start Tor service if API server is running and wallet is open.
if wallet.auto_start_tor_listener() && wallet.is_open() && api_server_running && if wallet.auto_start_tor_listener() && wallet.is_open() && !wallet.is_closing() &&
!Tor::is_service_running(&wallet.identifier()) { api_server_running && !Tor::is_service_running(&wallet.identifier()) {
let r_foreign_api = wallet.foreign_api_server.read(); let r_foreign_api = wallet.foreign_api_server.read();
let api = r_foreign_api.as_ref().unwrap(); let api = r_foreign_api.as_ref().unwrap();
if let Ok(sec_key) = wallet.secret_key() { if let Ok(sec_key) = wallet.secret_key() {
@ -1159,7 +1159,7 @@ fn start_sync(wallet: Wallet) -> Thread {
} }
// Stop sync if wallet was closed. // Stop sync if wallet was closed.
if !wallet.is_open() { if !wallet.is_open() || wallet.is_closing() {
on_thread_stop(wallet); on_thread_stop(wallet);
return; return;
} }
@ -1214,7 +1214,8 @@ fn sync_wallet_data(wallet: &Wallet, from_node: bool) {
config.min_confirmations config.min_confirmations
) { ) {
// Do not retrieve txs if wallet was closed or its first sync. // 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; return;
} }