From 65e002dc528f3951d39e353b87bc531885a943a6 Mon Sep 17 00:00:00 2001 From: Michael Mallan Date: Fri, 10 Jan 2025 15:39:28 +0000 Subject: [PATCH 1/3] refactor: treat as dyn state to easily add others Otherwise, all elements are expected to be `Home`. --- liana-gui/src/app/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/liana-gui/src/app/mod.rs b/liana-gui/src/app/mod.rs index a326f3617..93cbb4e8a 100644 --- a/liana-gui/src/app/mod.rs +++ b/liana-gui/src/app/mod.rs @@ -317,7 +317,7 @@ 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)]; let commands: Vec<_> = panels .iter_mut() .map(|(panel, menu)| { From 665c527dd08d027dbf95b22e58d44b1cb29212db Mon Sep 17 00:00:00 2001 From: Michael Mallan Date: Fri, 10 Jan 2025 16:57:45 +0000 Subject: [PATCH 2/3] fix: set rescan processing to false upon completion Otherwise, the button gets stuck on "Starting rescan...". --- liana-gui/src/app/mod.rs | 5 ++++- liana-gui/src/app/state/settings/bitcoind.rs | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/liana-gui/src/app/mod.rs b/liana-gui/src/app/mod.rs index 93cbb4e8a..cbfbb0269 100644 --- a/liana-gui/src/app/mod.rs +++ b/liana-gui/src/app/mod.rs @@ -317,7 +317,10 @@ 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 as &mut dyn State, 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)| { diff --git a/liana-gui/src/app/state/settings/bitcoind.rs b/liana-gui/src/app/state/settings/bitcoind.rs index 16d92953b..0c740e770 100644 --- a/liana-gui/src/app/state/settings/bitcoind.rs +++ b/liana-gui/src/app/state/settings/bitcoind.rs @@ -136,6 +136,9 @@ impl State for BitcoindSettingsState { self.rescan_settings.past_possible_height = true; self.rescan_settings.processing = false; } + Message::UpdatePanelCache(_, Ok(_)) => { + self.rescan_settings.processing = cache.rescan_progress.is_some_and(|p| p < 1.0); + } Message::View(view::Message::Settings(view::SettingsMessage::BitcoindSettings( msg, ))) => { From 130d004e79a1440e3d810ef35082f9671dc1ad81 Mon Sep 17 00:00:00 2001 From: Michael Mallan Date: Fri, 10 Jan 2025 17:01:37 +0000 Subject: [PATCH 3/3] refactor: do not include cache in message We already have access to the cache in the `update` arguments. --- liana-gui/src/app/message.rs | 2 +- liana-gui/src/app/mod.rs | 2 +- liana-gui/src/app/state/mod.rs | 2 +- liana-gui/src/app/state/settings/bitcoind.rs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/liana-gui/src/app/message.rs b/liana-gui/src/app/message.rs index 676446aca..dad49c931 100644 --- a/liana-gui/src/app/message.rs +++ b/liana-gui/src/app/message.rs @@ -19,7 +19,7 @@ use crate::{ pub enum Message { Tick, UpdateCache(Result), - UpdatePanelCache(/* is current panel */ bool, Result), + UpdatePanelCache(/* is current panel */ bool), View(view::Message), LoadDaemonConfig(Box), DaemonConfigLoaded(Result<(), Error>), diff --git a/liana-gui/src/app/mod.rs b/liana-gui/src/app/mod.rs index cbfbb0269..0b72b3826 100644 --- a/liana-gui/src/app/mod.rs +++ b/liana-gui/src/app/mod.rs @@ -327,7 +327,7 @@ impl App { panel.update( daemon.clone(), &cache, - Message::UpdatePanelCache(current == menu, Ok(cache.clone())), + Message::UpdatePanelCache(current == menu), ) }) .collect(); diff --git a/liana-gui/src/app/state/mod.rs b/liana-gui/src/app/state/mod.rs index d4f637b33..b848d0196 100644 --- a/liana-gui/src/app/state/mod.rs +++ b/liana-gui/src/app/state/mod.rs @@ -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(), diff --git a/liana-gui/src/app/state/settings/bitcoind.rs b/liana-gui/src/app/state/settings/bitcoind.rs index 0c740e770..f824efea7 100644 --- a/liana-gui/src/app/state/settings/bitcoind.rs +++ b/liana-gui/src/app/state/settings/bitcoind.rs @@ -136,7 +136,7 @@ impl State for BitcoindSettingsState { self.rescan_settings.past_possible_height = true; self.rescan_settings.processing = false; } - Message::UpdatePanelCache(_, Ok(_)) => { + Message::UpdatePanelCache(_) => { self.rescan_settings.processing = cache.rescan_progress.is_some_and(|p| p < 1.0); } Message::View(view::Message::Settings(view::SettingsMessage::BitcoindSettings(