Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

liana-gui: Iced v13 #1550

Merged
merged 8 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
806 changes: 394 additions & 412 deletions Cargo.lock

Large diffs are not rendered by default.

5 changes: 0 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,3 @@ members = [
"liana-ui",
]
default-members = ["liana", "lianad", "liana-gui", "liana-ui"]

[patch.crates-io]
iced_style = { git = "https://github.com/edouardparis/iced", branch = "patch-0.12.3"}
iced_winit = { git = "https://github.com/edouardparis/iced", branch = "patch-0.12.3"}
iced_futures = { git = "https://github.com/edouardparis/iced", branch = "patch-0.12.3"}
6 changes: 3 additions & 3 deletions liana-gui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ liana-ui = { path = "../liana-ui" }
backtrace = "0.3"
hex = "0.4.3"

iced = { version = "0.12.1", default-features = false, features = ["tokio", "svg", "qr_code", "image", "lazy", "wgpu", "advanced"] }
iced_runtime = "0.12.1"
iced = { version = "0.13.1", default-features = false, features = ["tokio", "svg", "qr_code", "image", "lazy", "wgpu", "advanced"] }
iced_runtime = "0.13.1"

# Used to verify RFC-compliance of an email
email_address = "0.2.7"
Expand All @@ -48,7 +48,7 @@ chrono = "0.4.38"
# Used for managing internal bitcoind
base64 = "0.21"
bitcoin_hashes = "0.12"
reqwest = { version = "0.11", default-features=false, features = ["json", "rustls-tls"] }
reqwest = { version = "0.11", default-features=false, features = ["json", "rustls-tls", "stream"] }
Copy link
Collaborator

@pythcoiner pythcoiner Feb 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe the PR summary should indicate what the stream feature is used for?

rust-ini = "0.19.0"
rfd = "0.15.1"

Expand Down
18 changes: 9 additions & 9 deletions liana-gui/src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use std::path::PathBuf;
use std::sync::Arc;
use std::time::Duration;

use iced::{clipboard, time, Command, Subscription};
use iced::{clipboard, time, Subscription, Task};
use tokio::runtime::Handle;
use tracing::{error, info, warn};

Expand Down Expand Up @@ -148,7 +148,7 @@ impl App {
daemon: Arc<dyn Daemon + Sync + Send>,
data_dir: PathBuf,
internal_bitcoind: Option<Bitcoind>,
) -> (App, Command<Message>) {
) -> (App, Task<Message>) {
let mut panels = Panels::new(
&cache,
wallet.clone(),
Expand All @@ -170,7 +170,7 @@ impl App {
)
}

fn set_current_panel(&mut self, menu: Menu) -> Command<Message> {
fn set_current_panel(&mut self, menu: Menu) -> Task<Message> {
self.panels.current_mut().interrupt();

match &menu {
Expand All @@ -183,7 +183,7 @@ impl App {
}) {
self.panels.transactions.preselect(tx);
self.panels.current = menu;
return Command::none();
return Task::none();
};
}
menu::Menu::PsbtPreSelected(txid) => {
Expand All @@ -198,7 +198,7 @@ impl App {
}) {
self.panels.psbts.preselect(spend_tx);
self.panels.current = menu;
return Command::none();
return Task::none();
};
}
menu::Menu::RefreshCoins(preselected) => {
Expand Down Expand Up @@ -279,14 +279,14 @@ impl App {
}
}

pub fn update(&mut self, message: Message) -> Command<Message> {
pub fn update(&mut self, message: Message) -> Task<Message> {
match message {
Message::Tick => {
let daemon = self.daemon.clone();
let datadir_path = self.cache.datadir_path.clone();
let network = self.cache.network;
let last_poll_at_startup = self.cache.last_poll_at_startup;
Command::perform(
Task::perform(
async move {
// we check every 10 second if the daemon poller is alive
// or if the access token is not expired.
Expand Down Expand Up @@ -331,11 +331,11 @@ impl App {
)
})
.collect();
return Command::batch(commands);
return Task::batch(commands);
}
Err(e) => tracing::error!("Failed to update cache: {}", e),
}
Command::none()
Task::none()
}
Message::LoadDaemonConfig(cfg) => {
let path = self.config.daemon_config_path.clone().expect(
Expand Down
14 changes: 7 additions & 7 deletions liana-gui/src/app/state/coins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::collections::HashMap;
use std::sync::Arc;
use std::{cmp::Ordering, collections::HashSet};

use iced::Command;
use iced::Task;

use liana_ui::widget::Element;
use lianad::commands::CoinStatus;
Expand Down Expand Up @@ -113,7 +113,7 @@ impl State for CoinsPanel {
daemon: Arc<dyn Daemon + Sync + Send>,
_cache: &Cache,
message: Message,
) -> Command<Message> {
) -> Task<Message> {
match message {
Message::Coins(res) => match res {
Err(e) => self.warning = Some(e),
Expand Down Expand Up @@ -150,18 +150,18 @@ impl State for CoinsPanel {
}
_ => {}
};
Command::none()
Task::none()
}

fn reload(
&mut self,
daemon: Arc<dyn Daemon + Sync + Send>,
_wallet: Arc<Wallet>,
) -> Command<Message> {
) -> Task<Message> {
let daemon1 = daemon.clone();
let daemon2 = daemon.clone();
Command::batch(vec![
Command::perform(
Task::batch(vec![
Task::perform(
async move {
daemon1
.list_coins(&[CoinStatus::Unconfirmed, CoinStatus::Confirmed], &[])
Expand All @@ -171,7 +171,7 @@ impl State for CoinsPanel {
},
Message::Coins,
),
Command::perform(
Task::perform(
async move {
let coins = daemon2
.list_coins(&[CoinStatus::Unconfirmed, CoinStatus::Confirmed], &[])
Expand Down
19 changes: 9 additions & 10 deletions liana-gui/src/app/state/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::{
sync::{Arc, Mutex},
};

use iced::{Command, Subscription};
use iced::{Subscription, Task};
use liana_ui::{component::modal::Modal, widget::Element};
use tokio::task::JoinHandle;

Expand Down Expand Up @@ -37,13 +37,13 @@ impl ExportModal {
}
}

pub fn launch(&self) -> Command<Message> {
Command::perform(get_path(), |m| {
pub fn launch(&self) -> Task<Message> {
Task::perform(get_path(), |m| {
Message::View(view::Message::Export(ExportMessage::Path(m)))
})
}

pub fn update(&mut self, message: Message) -> Command<Message> {
pub fn update(&mut self, message: Message) -> Task<Message> {
if let Message::View(view::Message::Export(m)) = message {
match m {
ExportMessage::ExportProgress(m) => match m {
Expand Down Expand Up @@ -73,16 +73,16 @@ impl ExportModal {
self.path = Some(path);
self.start();
} else {
return Command::perform(async {}, |_| {
return Task::perform(async {}, |_| {
Message::View(view::Message::Export(ExportMessage::Close))
});
}
}
ExportMessage::Close | ExportMessage::Open => { /* unreachable */ }
}
Command::none()
Task::none()
} else {
Command::none()
Task::none()
}
}
pub fn view<'a>(&'a self, content: Element<'a, view::Message>) -> Element<view::Message> {
Expand Down Expand Up @@ -115,10 +115,9 @@ impl ExportModal {
if let Some(path) = &self.path {
match &self.state {
ExportState::Started | ExportState::Progress(_) => {
Some(iced::subscription::unfold(
Some(iced::Subscription::run_with_id(
"transactions",
export::State::new(self.daemon.clone(), Box::new(path.to_path_buf())),
export::export_subscription,
export::export_subscription(self.daemon.clone(), path.to_path_buf()),
))
}
_ => None,
Expand Down
8 changes: 4 additions & 4 deletions liana-gui/src/app/state/label.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{
Daemon,
},
};
use iced::Command;
use iced::Task;
use liana_ui::component::form;

#[derive(Default)]
Expand All @@ -24,7 +24,7 @@ impl LabelsEdited {
daemon: Arc<dyn Daemon + Sync + Send>,
message: Message,
targets: T,
) -> Result<Command<Message>, Error> {
) -> Result<Task<Message>, Error> {
match message {
Message::View(view::Message::Label(items, msg)) => match msg {
view::LabelMessage::Edited(value) => {
Expand Down Expand Up @@ -64,7 +64,7 @@ impl LabelsEdited {
}
}
}
return Ok(Command::perform(
return Ok(Task::perform(
async move {
daemon.update_labels(&updated_labels).await?;
Ok(updated_labels_str)
Expand All @@ -88,7 +88,7 @@ impl LabelsEdited {
},
_ => {}
};
Ok(Command::none())
Ok(Task::none())
}
}

Expand Down
32 changes: 16 additions & 16 deletions liana-gui/src/app/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use std::convert::TryInto;
use std::sync::Arc;
use std::time::{SystemTime, UNIX_EPOCH};

use iced::{Command, Subscription};
use iced::{Subscription, Task};
use liana::miniscript::bitcoin::{Amount, OutPoint};
use liana_ui::widget::*;
use lianad::commands::CoinStatus;
Expand Down Expand Up @@ -50,8 +50,8 @@ pub trait State {
_daemon: Arc<dyn Daemon + Sync + Send>,
_cache: &Cache,
_message: Message,
) -> Command<Message> {
Command::none()
) -> Task<Message> {
Task::none()
}
fn subscription(&self) -> Subscription<Message> {
Subscription::none()
Expand All @@ -61,14 +61,14 @@ pub trait State {
&mut self,
_daemon: Arc<dyn Daemon + Sync + Send>,
_wallet: Arc<Wallet>,
) -> Command<Message> {
Command::none()
) -> Task<Message> {
Task::none()
}
}

/// redirect to another state with a message menu
pub fn redirect(menu: Menu) -> Command<Message> {
Command::perform(async { menu }, |menu| {
pub fn redirect(menu: Menu) -> Task<Message> {
Task::perform(async { menu }, |menu| {
Message::View(view::Message::Menu(menu))
})
}
Expand Down Expand Up @@ -201,7 +201,7 @@ impl State for Home {
daemon: Arc<dyn Daemon + Sync + Send>,
cache: &Cache,
message: Message,
) -> Command<Message> {
) -> Task<Message> {
match message {
Message::Coins(res) => match res {
Err(e) => self.warning = Some(e),
Expand Down Expand Up @@ -277,7 +277,7 @@ impl State for Home {
}
},
Message::View(view::Message::SelectPayment(outpoint)) => {
return Command::perform(
return Task::perform(
async move {
let tx = daemon.get_history_txs(&[outpoint.txid]).await?.remove(0);
Ok((tx, outpoint.vout as usize))
Expand Down Expand Up @@ -318,7 +318,7 @@ impl State for Home {
let daemon = daemon.clone();
let last_event_date = last.time.unwrap();
self.processing = true;
return Command::perform(
return Task::perform(
async move {
let last_event_date = last_event_date.timestamp() as u32;
let mut limit = HISTORY_EVENT_PAGE_SIZE;
Expand Down Expand Up @@ -359,20 +359,20 @@ impl State for Home {
}
_ => {}
};
Command::none()
Task::none()
}

fn reload(
&mut self,
daemon: Arc<dyn Daemon + Sync + Send>,
wallet: Arc<Wallet>,
) -> Command<Message> {
) -> Task<Message> {
// If the wallet is syncing, we expect it to finish soon and so better to wait for
// updated data before reloading. Besides, if the wallet is syncing, the DB may be
// locked if the poller is running and we wouldn't be able to reload data until
// syncing completes anyway.
if self.sync_status.wallet_is_syncing() {
return Command::none();
return Task::none();
}
self.selected_event = None;
self.wallet = wallet;
Expand All @@ -383,8 +383,8 @@ impl State for Home {
.as_secs()
.try_into()
.unwrap();
Command::batch(vec![
Command::perform(
Task::batch(vec![
Task::perform(
async move {
let mut payments = daemon
.list_confirmed_payments(0, now, HISTORY_EVENT_PAGE_SIZE)
Expand All @@ -397,7 +397,7 @@ impl State for Home {
},
Message::Payments,
),
Command::perform(
Task::perform(
async move {
daemon2
.list_coins(&[CoinStatus::Unconfirmed, CoinStatus::Confirmed], &[])
Expand Down
Loading
Loading