wallet: better handling of first sync on opening, tor connection status on wallet opening

This commit is contained in:
ardocrat 2024-05-18 10:20:38 +03:00
parent 960c806c5e
commit d8213c6d50
4 changed files with 15 additions and 12 deletions

View file

@ -83,9 +83,10 @@ impl WalletContent {
let data = wallet.get_data();
let data_empty = data.is_none();
// Show wallet balance panel when there is no error and data is not empty.
// Show wallet balance panel not on Settings tab, when wallet is not repairing,
// there is no error and data is not empty.
let show_balance = self.current_tab.get_type() != WalletTabType::Settings && !data_empty
&& !wallet.sync_error();
&& !wallet.sync_error() && !wallet.is_repairing();
egui::TopBottomPanel::top("wallet_balance")
.frame(egui::Frame {
fill: Colors::FILL,

View file

@ -197,7 +197,7 @@ impl WalletTransport {
}
// Draw send content.
if data.info.amount_currently_spendable > 0 {
if data.info.amount_currently_spendable > 0 && wallet.foreign_api_port().is_some() {
self.tor_send_ui(ui, cb);
}
}
@ -229,9 +229,8 @@ impl WalletTransport {
// Draw button to enable/disable Tor listener for current wallet.
let service_id = &wallet.identifier();
if !Tor::is_service_starting(service_id) {
if !Tor::is_service_running(service_id) &&
wallet.foreign_api_port().is_some() {
if !Tor::is_service_starting(service_id) && wallet.foreign_api_port().is_some() {
if !Tor::is_service_running(service_id) {
View::item_button(ui, Rounding::default(), POWER, Some(Colors::GREEN), || {
if let Ok(key) = wallet.secret_key() {
let api_port = wallet.foreign_api_port().unwrap();
@ -272,7 +271,8 @@ impl WalletTransport {
// Setup Tor status text.
let is_running = Tor::is_service_running(service_id);
let is_starting = Tor::is_service_starting(service_id);
let is_starting = Tor::is_service_starting(service_id) ||
wallet.foreign_api_port().is_none();
let has_error = Tor::is_service_failed(service_id);
let (icon, text) = if is_starting {
(DOTS_THREE_CIRCLE, t!("transport.connecting"))
@ -499,7 +499,8 @@ impl WalletTransport {
ui.add_space(3.0);
// Show wallet Slatepack address.
let address_color = if Tor::is_service_starting(service_id) {
let address_color = if Tor::is_service_starting(service_id) ||
wallet.foreign_api_port().is_none() {
Colors::INACTIVE_TEXT
} else if Tor::is_service_running(service_id) {
Colors::GREEN

View file

@ -191,7 +191,6 @@ impl WalletTransactions {
}
let refresh_resp = PullToRefresh::new(syncing && self.manual_sync)
.min_refresh_distance(70.0)
.can_refresh(!wallet.syncing())
.scroll_area_ui(ui, |ui| {
ScrollArea::vertical()
.id_source(Id::from("txs_content").with(wallet.get_config().id))
@ -213,8 +212,10 @@ impl WalletTransactions {
// Sync wallet on refresh.
if refresh_resp.should_refresh() {
wallet.sync(true);
self.manual_sync = true;
if !wallet.syncing() {
wallet.sync(true);
}
}
}

View file

@ -1164,8 +1164,8 @@ fn sync_wallet_data(wallet: &Wallet, from_node: bool) {
from_node,
config.min_confirmations
) {
// Do not retrieve txs if wallet was closed.
if !wallet.is_open() {
// Do not retrieve txs if wallet was closed or its first sync from local database.
if !wallet.is_open() || !from_node && info.1.last_confirmed_height == 0 {
return;
}