diff --git a/gui/src/app/mod.rs b/gui/src/app/mod.rs index 9e5a4b60..55f86bac 100644 --- a/gui/src/app/mod.rs +++ b/gui/src/app/mod.rs @@ -67,10 +67,13 @@ impl Panels { home: Home::new( wallet.clone(), &cache.coins, - cache.blockheight, - cache.sync_progress, - cache.last_poll_timestamp, - daemon_backend.clone(), + sync_status( + daemon_backend.clone(), + cache.blockheight, + cache.sync_progress, + cache.last_poll_timestamp, + cache.last_poll_at_startup, + ), ), coins: CoinsPanel::new(&cache.coins, wallet.main_descriptor.first_timelock_value()), transactions: TransactionsPanel::new(wallet.clone()), diff --git a/gui/src/app/state/mod.rs b/gui/src/app/state/mod.rs index 6694b248..682864a0 100644 --- a/gui/src/app/state/mod.rs +++ b/gui/src/app/state/mod.rs @@ -32,7 +32,7 @@ pub const HISTORY_EVENT_PAGE_SIZE: u64 = 20; use crate::daemon::{ model::{remaining_sequence, Coin, HistoryTransaction, Labelled}, - Daemon, DaemonBackend, + Daemon, }; pub use coins::CoinsPanel; use label::LabelsEdited; @@ -76,7 +76,6 @@ pub fn redirect(menu: Menu) -> Command { pub struct Home { wallet: Arc, sync_status: SyncStatus, - last_poll_at_startup: Option, balance: Amount, unconfirmed_balance: Amount, remaining_sequence: Option, @@ -91,14 +90,7 @@ pub struct Home { } impl Home { - pub fn new( - wallet: Arc, - coins: &[Coin], - blockheight: i32, - sync_progress: f64, - last_poll: Option, - daemon_backend: DaemonBackend, - ) -> Self { + pub fn new(wallet: Arc, coins: &[Coin], sync_status: SyncStatus) -> Self { let (balance, unconfirmed_balance) = coins.iter().fold( (Amount::from_sat(0), Amount::from_sat(0)), |(balance, unconfirmed_balance), coin| { @@ -112,18 +104,9 @@ impl Home { }, ); - let sync_status = sync_status( - daemon_backend, - blockheight, - sync_progress, - last_poll, - last_poll, - ); - Self { wallet, sync_status, - last_poll_at_startup: last_poll, balance, unconfirmed_balance, remaining_sequence: None, @@ -137,22 +120,6 @@ impl Home { processing: false, } } - - fn sync_status( - &self, - daemon_backend: DaemonBackend, - blockheight: i32, - sync_progress: f64, - last_poll: Option, - ) -> SyncStatus { - sync_status( - daemon_backend, - blockheight, - sync_progress, - last_poll, - self.last_poll_at_startup, - ) - } } impl State for Home { @@ -263,11 +230,12 @@ impl State for Home { }, Message::UpdatePanelCache(is_current, Ok(cache)) => { let wallet_was_syncing = !self.sync_status.is_synced(); - self.sync_status = self.sync_status( + self.sync_status = sync_status( daemon.backend(), cache.blockheight, cache.sync_progress, cache.last_poll_timestamp, + cache.last_poll_at_startup, ); // If this is the current panel, reload it if wallet is no longer syncing. if is_current && wallet_was_syncing && self.sync_status.is_synced() {