From 0416a3645ab98971ba45eec9646b9934e33188f1 Mon Sep 17 00:00:00 2001 From: edouard Date: Wed, 1 Feb 2023 17:53:22 +0100 Subject: [PATCH] Add liana version in gui settings close #243 --- gui/Cargo.lock | 2 +- gui/src/app/state/settings.rs | 19 +++++++++++++++++++ gui/src/app/view/settings.rs | 24 +++++++++++++++++++++++- gui/src/lib.rs | 8 ++++++++ 4 files changed, 51 insertions(+), 2 deletions(-) diff --git a/gui/Cargo.lock b/gui/Cargo.lock index 637f78b1..3b1e5343 100644 --- a/gui/Cargo.lock +++ b/gui/Cargo.lock @@ -1640,7 +1640,7 @@ dependencies = [ [[package]] name = "liana" version = "0.1.0" -source = "git+https://github.com/wizardsardine/liana?branch=master#f433002e91b09ab700d06026e1d94c462aca9756" +source = "git+https://github.com/wizardsardine/liana?branch=master#bd6ecaeb285f780ea94e38e28b2d0860f1b45c97" dependencies = [ "backtrace", "base64", diff --git a/gui/src/app/state/settings.rs b/gui/src/app/state/settings.rs index c6240325..29d7d093 100644 --- a/gui/src/app/state/settings.rs +++ b/gui/src/app/state/settings.rs @@ -31,6 +31,7 @@ pub struct SettingsState { warning: Option, config_updated: bool, daemon_is_external: bool, + daemon_version: Option, settings: Vec>, current: Option, @@ -52,6 +53,11 @@ impl SettingsState { }; SettingsState { + daemon_version: if !daemon_is_external { + Some(liana::VERSION.to_string()) + } else { + None + }, daemon_is_external, warning: None, config_updated: false, @@ -94,6 +100,7 @@ impl State for SettingsState { Message::Info(res) => match res { Err(e) => self.warning = Some(e), Ok(info) => { + self.daemon_version = Some(info.version); if info.rescan_progress == Some(1.0) { self.settings[1].edited(true); } @@ -117,6 +124,7 @@ impl State for SettingsState { fn view<'a>(&'a self, cache: &'a Cache) -> Element<'a, view::Message> { let can_edit = self.current.is_none() && !self.daemon_is_external; view::settings::list( + self.daemon_version.as_ref(), cache, self.warning.as_ref(), self.settings @@ -130,6 +138,17 @@ impl State for SettingsState { .collect(), ) } + + fn load(&self, daemon: Arc) -> Command { + if self.daemon_version.is_none() { + Command::perform( + async move { daemon.get_info().map_err(|e| e.into()) }, + Message::Info, + ) + } else { + Command::none() + } + } } impl From for Box { diff --git a/gui/src/app/view/settings.rs b/gui/src/app/view/settings.rs index b5c9dfcd..28246bbb 100644 --- a/gui/src/app/view/settings.rs +++ b/gui/src/app/view/settings.rs @@ -24,6 +24,7 @@ use crate::{ }; pub fn list<'a>( + lianad_version: Option<&'a String>, cache: &'a Cache, warning: Option<&Error>, settings: Vec>, @@ -54,7 +55,28 @@ pub fn list<'a>( .push(Space::with_width(Length::Fill)) .push(button::primary(None, "Recover funds").on_press(Message::Menu(Menu::Recovery))), ), - )), + )) + .push( + card::simple( + Column::new() + .push( + Row::new() + .push(badge::Badge::new(icon::tooltip_icon())) + .push(text("About").bold()) + .padding(10) + .spacing(20) + .align_items(Alignment::Center) + .width(Length::Fill), + ) + .push(separation().width(Length::Fill)) + .push(Space::with_height(Length::Units(10))) + .push( + Row::new().push(Space::with_width(Length::Fill)).push(Column::new() + .push(text(format!("liana-gui v{}", crate::VERSION))) + .push_maybe(lianad_version.map(|version| text(format!("lianad v{}", version))))) + ) + ).width(Length::Fill) + ) ) } diff --git a/gui/src/lib.rs b/gui/src/lib.rs index e3d7c750..3b60c731 100644 --- a/gui/src/lib.rs +++ b/gui/src/lib.rs @@ -6,3 +6,11 @@ pub mod launcher; pub mod loader; pub mod ui; pub mod utils; + +use liana::Version; + +pub const VERSION: Version = Version { + major: 0, + minor: 1, + patch: 0, +};