Merge #1530: Fix update of rescan state upon completion

130d004e79a1440e3d810ef35082f9671dc1ad81 refactor: do not include cache in message (Michael Mallan)
665c527dd08d027dbf95b22e58d44b1cb29212db fix: set rescan processing to false upon completion (Michael Mallan)
65e002dc528f3951d39e353b87bc531885a943a6 refactor: treat as dyn state to easily add others (Michael Mallan)

Pull request description:

  This is to fix #1528.

  It updates the `processing` field of the rescan settings each time the cache is updated.

ACKs for top commit:
  edouardparis:
    ACK 130d004e79a1440e3d810ef35082f9671dc1ad81

Tree-SHA512: 7edd744510edf799ab7f00cceee31e60ce316f3cd0c8377d7693064b4cf0c9ac12520f0c55a3c3305866c3cb98684378640ab2944c0dc76969cac9209ce3bce9
This commit is contained in:
edouardparis 2025-01-13 10:12:46 +01:00
commit f46efa2a33
No known key found for this signature in database
GPG Key ID: E65F7A089C20DC8F
4 changed files with 10 additions and 4 deletions

View File

@ -19,7 +19,7 @@ use crate::{
pub enum Message {
Tick,
UpdateCache(Result<Cache, Error>),
UpdatePanelCache(/* is current panel */ bool, Result<Cache, Error>),
UpdatePanelCache(/* is current panel */ bool),
View(view::Message),
LoadDaemonConfig(Box<DaemonConfig>),
DaemonConfigLoaded(Result<(), Error>),

View File

@ -317,14 +317,17 @@ impl App {
let current = &self.panels.current;
let daemon = self.daemon.clone();
// These are the panels to update with the cache.
let mut panels = [(&mut self.panels.home, Menu::Home)];
let mut panels = [
(&mut self.panels.home as &mut dyn State, Menu::Home),
(&mut self.panels.settings as &mut dyn State, Menu::Settings),
];
let commands: Vec<_> = panels
.iter_mut()
.map(|(panel, menu)| {
panel.update(
daemon.clone(),
&cache,
Message::UpdatePanelCache(current == menu, Ok(cache.clone())),
Message::UpdatePanelCache(current == menu),
)
})
.collect();

View File

@ -254,7 +254,7 @@ impl State for Home {
}
}
},
Message::UpdatePanelCache(is_current, Ok(cache)) => {
Message::UpdatePanelCache(is_current) => {
let wallet_was_syncing = !self.sync_status.is_synced();
self.sync_status = sync_status(
daemon.backend(),

View File

@ -136,6 +136,9 @@ impl State for BitcoindSettingsState {
self.rescan_settings.past_possible_height = true;
self.rescan_settings.processing = false;
}
Message::UpdatePanelCache(_) => {
self.rescan_settings.processing = cache.rescan_progress.is_some_and(|p| p < 1.0);
}
Message::View(view::Message::Settings(view::SettingsMessage::BitcoindSettings(
msg,
))) => {