gui: make ExportModal.daemon optionnal
This commit is contained in:
parent
530b8c12bc
commit
5dcecc5542
@ -19,13 +19,16 @@ pub struct ExportModal {
|
||||
handle: Option<Arc<Mutex<JoinHandle<()>>>>,
|
||||
state: ImportExportState,
|
||||
error: Option<export::Error>,
|
||||
daemon: Arc<dyn Daemon + Sync + Send>,
|
||||
daemon: Option<Arc<dyn Daemon + Sync + Send>>,
|
||||
import_export_type: ImportExportType,
|
||||
}
|
||||
|
||||
impl ExportModal {
|
||||
#[allow(clippy::new_without_default)]
|
||||
pub fn new(daemon: Arc<dyn Daemon + Sync + Send>, export_type: ImportExportType) -> Self {
|
||||
pub fn new(
|
||||
daemon: Option<Arc<dyn Daemon + Sync + Send>>,
|
||||
export_type: ImportExportType,
|
||||
) -> Self {
|
||||
Self {
|
||||
path: None,
|
||||
handle: None,
|
||||
|
||||
@ -236,7 +236,7 @@ impl State for ImportExportSettingsState {
|
||||
Message::View(view::Message::Settings(view::SettingsMessage::ExportDescriptor)) => {
|
||||
if self.modal.is_none() {
|
||||
let modal = ExportModal::new(
|
||||
daemon,
|
||||
Some(daemon),
|
||||
ImportExportType::Descriptor(self.wallet.main_descriptor.clone()),
|
||||
);
|
||||
launch!(self, modal);
|
||||
@ -244,13 +244,13 @@ impl State for ImportExportSettingsState {
|
||||
}
|
||||
Message::View(view::Message::Settings(view::SettingsMessage::ExportTransactions)) => {
|
||||
if self.modal.is_none() {
|
||||
let modal = ExportModal::new(daemon, ImportExportType::Transactions);
|
||||
let modal = ExportModal::new(Some(daemon), ImportExportType::Transactions);
|
||||
launch!(self, modal);
|
||||
}
|
||||
}
|
||||
Message::View(view::Message::Settings(view::SettingsMessage::ExportLabels)) => {
|
||||
if self.modal.is_none() {
|
||||
let modal = ExportModal::new(daemon, ImportExportType::ExportLabels);
|
||||
let modal = ExportModal::new(Some(daemon), ImportExportType::ExportLabels);
|
||||
launch!(self, modal);
|
||||
}
|
||||
}
|
||||
@ -278,7 +278,7 @@ impl State for ImportExportSettingsState {
|
||||
}
|
||||
}
|
||||
Message::View(view::Message::Settings(view::SettingsMessage::ExportBackup(backup))) => {
|
||||
let modal = ExportModal::new(daemon, ImportExportType::ExportBackup(backup));
|
||||
let modal = ExportModal::new(Some(daemon), ImportExportType::ExportBackup(backup));
|
||||
launch!(self, modal);
|
||||
}
|
||||
Message::View(view::Message::Settings(view::SettingsMessage::ImportWallet)) => {
|
||||
|
||||
@ -252,7 +252,7 @@ impl State for WalletSettingsState {
|
||||
if self.modal.is_none() {
|
||||
let modal =
|
||||
// ExportModal::new(Some(daemon), ImportExportType::ExportBackup(backup));
|
||||
ExportModal::new(daemon, ImportExportType::ExportBackup(backup));
|
||||
ExportModal::new(Some(daemon), ImportExportType::ExportBackup(backup));
|
||||
let launch = modal.launch();
|
||||
self.modal = Modal::ImportExport(modal);
|
||||
launch
|
||||
@ -264,7 +264,7 @@ impl State for WalletSettingsState {
|
||||
if self.modal.is_none() {
|
||||
let modal = ExportModal::new(
|
||||
// Some(daemon),
|
||||
daemon,
|
||||
Some(daemon),
|
||||
ImportExportType::Descriptor(self.wallet.main_descriptor.clone()),
|
||||
);
|
||||
let launch = modal.launch();
|
||||
|
||||
@ -269,7 +269,7 @@ impl State for TransactionsPanel {
|
||||
Message::View(view::Message::ImportExport(ImportExportMessage::Open)) => {
|
||||
if let TransactionsModal::None = &self.modal {
|
||||
self.modal = TransactionsModal::Export(ExportModal::new(
|
||||
daemon,
|
||||
Some(daemon),
|
||||
ImportExportType::Transactions,
|
||||
));
|
||||
if let TransactionsModal::Export(m) = &self.modal {
|
||||
|
||||
@ -260,12 +260,12 @@ impl Export {
|
||||
}
|
||||
|
||||
pub fn export_subscription(
|
||||
daemon: Arc<dyn Daemon + Sync + Send>,
|
||||
daemon: Option<Arc<dyn Daemon + Sync + Send>>,
|
||||
path: PathBuf,
|
||||
export_type: ImportExportType,
|
||||
) -> impl Stream<Item = Progress> {
|
||||
iced::stream::channel(100, move |mut output| async move {
|
||||
let mut state = Export::new(Some(daemon), Box::new(path), export_type);
|
||||
let mut state = Export::new(daemon, Box::new(path), export_type);
|
||||
loop {
|
||||
match state.state() {
|
||||
Status::Init => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user