From 44232ede585e772c11b23460516c76a50961f85c Mon Sep 17 00:00:00 2001 From: alemi Date: Sat, 28 Dec 2024 19:06:43 +0100 Subject: [PATCH] feat(web): show BE and FE versions differently BE version must be fetched from BE nodeinfo but I think we can afford an extra request :p --- web/src/app.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/web/src/app.rs b/web/src/app.rs index 7b1be0a..c8dfcc3 100644 --- a/web/src/app.rs +++ b/web/src/app.rs @@ -81,6 +81,22 @@ pub fn App() -> impl IntoView { let auth = Auth { token, userid }; + let (be_version, set_be_version) = create_signal("?.?.?".to_string()); + spawn_local(async move { + match Http::fetch::(&format!("{URL_BASE}/nodeinfo/2.0.json"), auth).await { + Err(e) => tracing::error!("failed fetching backend version: {e} - {e:?}"), + Ok(nodeinfo) => { + if let Some(version) = nodeinfo + .get("software") + .and_then(|x| x.get("version")) + .and_then(|x| x.as_str()) + { + set_be_version.set(version.to_string()); + } + }, + } + }); + let username = auth.userid.get_untracked() .map(|x| x.split('/').last().unwrap_or_default().to_string()) .unwrap_or_default(); @@ -206,7 +222,7 @@ pub fn App() -> impl IntoView { }