From a8c5a164ff86c38a35d0aa3a2ce49bf6e4674171 Mon Sep 17 00:00:00 2001 From: Bill Thiede Date: Sun, 1 Sep 2024 15:02:34 -0700 Subject: [PATCH] web: clean up version string and reload on mismatch --- shared/src/lib.rs | 4 ++-- web/src/state.rs | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/shared/src/lib.rs b/shared/src/lib.rs index 9ccdca4..17968d3 100644 --- a/shared/src/lib.rs +++ b/shared/src/lib.rs @@ -39,7 +39,7 @@ pub fn build_version(bi:fn()->&'static BuildInfo) -> String { let Some(VersionControl::Git(git)) = git else { return String::new(); }; - let mut s = vec![git.commit_short_id.clone()]; + let mut s = vec!["-".to_string(), git.commit_short_id.clone()]; if git.dirty { s.push(".+".to_string()); } @@ -51,5 +51,5 @@ pub fn build_version(bi:fn()->&'static BuildInfo) -> String { } let bi = bi(); - format!("{}-{}", bi.crate_info.version, commit(&bi.version_control)).to_string() + format!("v{}{}", bi.crate_info.version, commit(&bi.version_control)).to_string() } diff --git a/web/src/state.rs b/web/src/state.rs index 60964ec..074f58f 100644 --- a/web/src/state.rs +++ b/web/src/state.rs @@ -519,9 +519,10 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders) { Msg::UpdateServerVersion(version) => { if version != model.versions.client { warn!( - "Server ({}) and client ({}) version mismatch", + "Server ({}) and client ({}) version mismatch, reloading", version, model.versions.client ); + orders.send_msg(Msg::Reload); } model.versions.server = Some(version); }