Merge #303: Add liana version in gui settings

0416a3645ab98971ba45eec9646b9934e33188f1 Add liana version in gui settings (edouard)

Pull request description:

  close #243

ACKs for top commit:
  edouardparis:
    Self-ACK 0416a3645ab98971ba45eec9646b9934e33188f1

Tree-SHA512: 7f3d516ef0c1784b0f6da7ceb0c026748db6ecd35147340ba88f66d520f89aba0dcad23b02804fb922de9ef204c54f86b007321d336d31cff58254a028140317
This commit is contained in:
edouard 2023-02-02 16:11:53 +01:00
commit d5baf1bd57
No known key found for this signature in database
GPG Key ID: E65F7A089C20DC8F
4 changed files with 51 additions and 2 deletions

2
gui/Cargo.lock generated
View File

@ -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",

View File

@ -31,6 +31,7 @@ pub struct SettingsState {
warning: Option<Error>,
config_updated: bool,
daemon_is_external: bool,
daemon_version: Option<String>,
settings: Vec<Box<dyn Setting>>,
current: Option<usize>,
@ -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<dyn Daemon + Sync + Send>) -> Command<Message> {
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<SettingsState> for Box<dyn State> {

View File

@ -24,6 +24,7 @@ use crate::{
};
pub fn list<'a>(
lianad_version: Option<&'a String>,
cache: &'a Cache,
warning: Option<&Error>,
settings: Vec<Element<'a, Message>>,
@ -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)
)
)
}

View File

@ -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,
};