installer: refresh hw list only if modal is open
This commit is contained in:
parent
4e2015922d
commit
570f0af35b
@ -204,6 +204,7 @@ impl HardwareWallets {
|
||||
|
||||
pub fn set_network(&mut self, network: Network) {
|
||||
self.network = network;
|
||||
self.list = Vec::new();
|
||||
}
|
||||
|
||||
pub fn update(
|
||||
|
||||
@ -73,13 +73,10 @@ impl Installer {
|
||||
|
||||
pub fn subscription(&self) -> Subscription<Message> {
|
||||
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()
|
||||
}
|
||||
|
||||
@ -739,7 +739,7 @@ impl Step for InternalBitcoindStep {
|
||||
Command::none()
|
||||
}
|
||||
|
||||
fn subscription(&self) -> Subscription<Message> {
|
||||
fn subscription(&self, _hws: &HardwareWallets) -> Subscription<Message> {
|
||||
if let Some(download) = self.exe_download.as_ref() {
|
||||
return download.subscription();
|
||||
}
|
||||
|
||||
@ -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<Message> {
|
||||
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<Message> {
|
||||
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<Message> {
|
||||
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<Message> {
|
||||
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<Message> {
|
||||
hws.refresh().map(Message::HardwareWallets)
|
||||
}
|
||||
fn load(&self) -> Command<Message> {
|
||||
Command::none()
|
||||
}
|
||||
|
||||
@ -28,7 +28,7 @@ pub trait Step {
|
||||
fn update(&mut self, _hws: &mut HardwareWallets, _message: Message) -> Command<Message> {
|
||||
Command::none()
|
||||
}
|
||||
fn subscription(&self) -> Subscription<Message> {
|
||||
fn subscription(&self, _hws: &HardwareWallets) -> Subscription<Message> {
|
||||
Subscription::none()
|
||||
}
|
||||
fn view<'a>(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user