gui: reload home if wallet is not syncing

This commit is contained in:
Michael Mallan 2024-11-05 15:04:58 +00:00
parent 327f0ea665
commit 71ad55e06b
No known key found for this signature in database
GPG Key ID: 5177CDCEDB0EABEB
2 changed files with 10 additions and 2 deletions

View File

@ -313,8 +313,11 @@ impl State for Home {
daemon: Arc<dyn Daemon + Sync + Send>,
wallet: Arc<Wallet>,
) -> Command<Message> {
// Wait for wallet to finish syncing before reloading data.
if !self.sync_status.is_synced() {
// If the wallet is syncing, we expect it to finish soon and so better to wait for
// updated data before reloading. Besides, if the wallet is syncing, the DB may be
// locked if the poller is running and we wouldn't be able to reload data until
// syncing completes anyway.
if self.sync_status.wallet_is_syncing() {
return Command::none();
}
self.selected_event = None;

View File

@ -207,6 +207,11 @@ impl SyncStatus {
pub fn is_synced(&self) -> bool {
self == &SyncStatus::Synced
}
/// Whether the wallet itself, and not the blockchain, is syncing.
pub fn wallet_is_syncing(&self) -> bool {
self == &SyncStatus::WalletFullScan || self == &SyncStatus::LatestWalletSync
}
}
/// Get the [`SyncStatus`].