Merge #1437: gui: reload home if wallet is not syncing

71ad55e06bfc804754983debd7502db02b6bc524 gui: reload home if wallet is not syncing (Michael Mallan)

Pull request description:

  Following #1386, this PR will show past payments on the home page while the blockchain is still syncing. Currently, these are not loaded until the wallet has finished syncing.

  This change won't apply if the wallet itself is still syncing. The reason is that this is not expected to take so long and so it's better to wait for the updated data. Furthermore, the DB may be locked if the poller is running, in which case we wouldn't be able to load past transactions until the wallet has synced anyway. The home page reloads automatically as soon as the wallet finishes syncing.

ACKs for top commit:
  edouardparis:
    utACK 71ad55e06bfc804754983debd7502db02b6bc524

Tree-SHA512: 5fcf179ec859616ff1d7150597e73e20cb2ef0aa3ad882eeea37d6149754e58b44e37d6553ecb690a60383a95228f9724ec812dc4ae825d2620d377861c31e19
This commit is contained in:
edouardparis 2024-11-18 09:22:04 +01:00
commit 27dce54c13
No known key found for this signature in database
GPG Key ID: E65F7A089C20DC8F
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`].