From c0fd7cf0aa71d405a9753e2d6369356d1a832a4b Mon Sep 17 00:00:00 2001 From: ardocrat Date: Wed, 1 May 2024 04:11:46 +0300 Subject: [PATCH] fix: tor transport buttons on service start --- src/gui/views/wallets/wallet/transport.rs | 25 +++++++++++++---------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/gui/views/wallets/wallet/transport.rs b/src/gui/views/wallets/wallet/transport.rs index 29b566d..d7c2af7 100644 --- a/src/gui/views/wallets/wallet/transport.rs +++ b/src/gui/views/wallets/wallet/transport.rs @@ -190,17 +190,20 @@ impl WalletTransport { // Draw button to enable/disable Tor listener for current wallet. let service_id = &wallet.identifier(); - if !Tor::is_service_running(service_id) && - wallet.foreign_api_port().is_some() { - View::item_button(ui, Rounding::default(), POWER, Some(Colors::GREEN), || { - if let Ok(key) = wallet.secret_key() { - Tor::start_service(wallet.foreign_api_port().unwrap(), key, service_id); - } - }); - } else if !Tor::is_service_starting(service_id) { - View::item_button(ui, Rounding::default(), POWER, Some(Colors::RED), || { - Tor::stop_service(service_id); - }); + if !Tor::is_service_starting(service_id) { + if !Tor::is_service_running(service_id) && + wallet.foreign_api_port().is_some() { + 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(); + Tor::start_service(api_port, key, service_id); + } + }); + } else { + View::item_button(ui, Rounding::default(), POWER, Some(Colors::RED), || { + Tor::stop_service(service_id); + }); + } } let layout_size = ui.available_size();