wallet: better handling of first sync on opening, tor connection status on wallet opening
This commit is contained in:
parent
960c806c5e
commit
d8213c6d50
4 changed files with 15 additions and 12 deletions
|
@ -83,9 +83,10 @@ impl WalletContent {
|
||||||
let data = wallet.get_data();
|
let data = wallet.get_data();
|
||||||
let data_empty = data.is_none();
|
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
|
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")
|
egui::TopBottomPanel::top("wallet_balance")
|
||||||
.frame(egui::Frame {
|
.frame(egui::Frame {
|
||||||
fill: Colors::FILL,
|
fill: Colors::FILL,
|
||||||
|
|
|
@ -197,7 +197,7 @@ impl WalletTransport {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw send content.
|
// 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);
|
self.tor_send_ui(ui, cb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -229,9 +229,8 @@ impl WalletTransport {
|
||||||
|
|
||||||
// Draw button to enable/disable Tor listener for current wallet.
|
// Draw button to enable/disable Tor listener for current wallet.
|
||||||
let service_id = &wallet.identifier();
|
let service_id = &wallet.identifier();
|
||||||
if !Tor::is_service_starting(service_id) {
|
if !Tor::is_service_starting(service_id) && wallet.foreign_api_port().is_some() {
|
||||||
if !Tor::is_service_running(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), || {
|
View::item_button(ui, Rounding::default(), POWER, Some(Colors::GREEN), || {
|
||||||
if let Ok(key) = wallet.secret_key() {
|
if let Ok(key) = wallet.secret_key() {
|
||||||
let api_port = wallet.foreign_api_port().unwrap();
|
let api_port = wallet.foreign_api_port().unwrap();
|
||||||
|
@ -272,7 +271,8 @@ impl WalletTransport {
|
||||||
|
|
||||||
// Setup Tor status text.
|
// Setup Tor status text.
|
||||||
let is_running = Tor::is_service_running(service_id);
|
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 has_error = Tor::is_service_failed(service_id);
|
||||||
let (icon, text) = if is_starting {
|
let (icon, text) = if is_starting {
|
||||||
(DOTS_THREE_CIRCLE, t!("transport.connecting"))
|
(DOTS_THREE_CIRCLE, t!("transport.connecting"))
|
||||||
|
@ -499,7 +499,8 @@ impl WalletTransport {
|
||||||
ui.add_space(3.0);
|
ui.add_space(3.0);
|
||||||
|
|
||||||
// Show wallet Slatepack address.
|
// 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
|
Colors::INACTIVE_TEXT
|
||||||
} else if Tor::is_service_running(service_id) {
|
} else if Tor::is_service_running(service_id) {
|
||||||
Colors::GREEN
|
Colors::GREEN
|
||||||
|
|
|
@ -191,7 +191,6 @@ impl WalletTransactions {
|
||||||
}
|
}
|
||||||
let refresh_resp = PullToRefresh::new(syncing && self.manual_sync)
|
let refresh_resp = PullToRefresh::new(syncing && self.manual_sync)
|
||||||
.min_refresh_distance(70.0)
|
.min_refresh_distance(70.0)
|
||||||
.can_refresh(!wallet.syncing())
|
|
||||||
.scroll_area_ui(ui, |ui| {
|
.scroll_area_ui(ui, |ui| {
|
||||||
ScrollArea::vertical()
|
ScrollArea::vertical()
|
||||||
.id_source(Id::from("txs_content").with(wallet.get_config().id))
|
.id_source(Id::from("txs_content").with(wallet.get_config().id))
|
||||||
|
@ -213,8 +212,10 @@ impl WalletTransactions {
|
||||||
|
|
||||||
// Sync wallet on refresh.
|
// Sync wallet on refresh.
|
||||||
if refresh_resp.should_refresh() {
|
if refresh_resp.should_refresh() {
|
||||||
wallet.sync(true);
|
|
||||||
self.manual_sync = true;
|
self.manual_sync = true;
|
||||||
|
if !wallet.syncing() {
|
||||||
|
wallet.sync(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1164,8 +1164,8 @@ fn sync_wallet_data(wallet: &Wallet, from_node: bool) {
|
||||||
from_node,
|
from_node,
|
||||||
config.min_confirmations
|
config.min_confirmations
|
||||||
) {
|
) {
|
||||||
// Do not retrieve txs if wallet was closed.
|
// Do not retrieve txs if wallet was closed or its first sync from local database.
|
||||||
if !wallet.is_open() {
|
if !wallet.is_open() || !from_node && info.1.last_confirmed_height == 0 {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue