diff --git a/gui/src/hw.rs b/gui/src/hw.rs index 78093c60..15127ac9 100644 --- a/gui/src/hw.rs +++ b/gui/src/hw.rs @@ -204,6 +204,7 @@ impl HardwareWallets { pub fn set_network(&mut self, network: Network) { self.network = network; + self.list = Vec::new(); } pub fn update( diff --git a/gui/src/installer/mod.rs b/gui/src/installer/mod.rs index 0b5bac74..aa842d9b 100644 --- a/gui/src/installer/mod.rs +++ b/gui/src/installer/mod.rs @@ -73,13 +73,10 @@ impl Installer { pub fn subscription(&self) -> Subscription { if self.current > 0 { - Subscription::batch(vec![ - self.hws.refresh().map(Message::HardwareWallets), - self.steps - .get(self.current) - .expect("There is always a step") - .subscription(), - ]) + self.steps + .get(self.current) + .expect("There is always a step") + .subscription(&self.hws) } else { Subscription::none() } diff --git a/gui/src/installer/step/bitcoind.rs b/gui/src/installer/step/bitcoind.rs index 60b24853..1fe2c13d 100644 --- a/gui/src/installer/step/bitcoind.rs +++ b/gui/src/installer/step/bitcoind.rs @@ -739,7 +739,7 @@ impl Step for InternalBitcoindStep { Command::none() } - fn subscription(&self) -> Subscription { + fn subscription(&self, _hws: &HardwareWallets) -> Subscription { if let Some(download) = self.exe_download.as_ref() { return download.subscription(); } diff --git a/gui/src/installer/step/descriptor.rs b/gui/src/installer/step/descriptor.rs index c5167d05..40b13fb0 100644 --- a/gui/src/installer/step/descriptor.rs +++ b/gui/src/installer/step/descriptor.rs @@ -4,7 +4,7 @@ use std::path::PathBuf; use std::str::FromStr; use std::sync::{Arc, Mutex}; -use iced::Command; +use iced::{Command, Subscription}; use liana::miniscript::bitcoin::bip32::Xpub; use liana::{ descriptors::{LianaDescriptor, LianaPolicy, PathInfo}, @@ -46,6 +46,9 @@ pub trait DescriptorEditModal { Command::none() } fn view<'a>(&'a self, _hws: &'a HardwareWallets) -> Element<'a, Message>; + fn subscription(&self, _hws: &HardwareWallets) -> Subscription { + Subscription::none() + } } pub struct RecoveryPath { @@ -461,6 +464,14 @@ impl Step for DefineDescriptor { self.set_network(ctx.bitcoin_config.network) } + fn subscription(&self, hws: &HardwareWallets) -> Subscription { + if let Some(modal) = &self.modal { + modal.subscription(hws) + } else { + Subscription::none() + } + } + fn apply(&mut self, ctx: &mut Context) -> bool { ctx.bitcoin_config.network = self.network; ctx.keys = Vec::new(); @@ -1013,6 +1024,11 @@ impl DescriptorEditModal for EditXpubModal { }; Command::none() } + + fn subscription(&self, hws: &HardwareWallets) -> Subscription { + hws.refresh().map(Message::HardwareWallets) + } + fn view<'a>(&'a self, hws: &'a HardwareWallets) -> Element<'a, Message> { let chosen_signer = self.chosen_signer.as_ref().map(|s| s.0); view::edit_key_modal( @@ -1272,6 +1288,10 @@ impl Step for ParticipateXpub { Command::none() } + fn subscription(&self, hws: &HardwareWallets) -> Subscription { + hws.refresh().map(Message::HardwareWallets) + } + fn load_context(&mut self, ctx: &Context) { self.data_dir = Some(ctx.data_dir.clone()); self.set_network(ctx.bitcoin_config.network); @@ -1550,6 +1570,9 @@ impl Step for RegisterDescriptor { } true } + fn subscription(&self, hws: &HardwareWallets) -> Subscription { + hws.refresh().map(Message::HardwareWallets) + } fn load(&self) -> Command { Command::none() } diff --git a/gui/src/installer/step/mod.rs b/gui/src/installer/step/mod.rs index 15529629..29365c08 100644 --- a/gui/src/installer/step/mod.rs +++ b/gui/src/installer/step/mod.rs @@ -28,7 +28,7 @@ pub trait Step { fn update(&mut self, _hws: &mut HardwareWallets, _message: Message) -> Command { Command::none() } - fn subscription(&self) -> Subscription { + fn subscription(&self, _hws: &HardwareWallets) -> Subscription { Subscription::none() } fn view<'a>(