Add server and client build versions
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
use std::collections::HashSet;
|
||||
|
||||
use graphql_client::GraphQLQuery;
|
||||
use log::{error, info};
|
||||
use log::{error, info, warn};
|
||||
use seed::{prelude::*, *};
|
||||
use thiserror::Error;
|
||||
|
||||
@@ -27,6 +27,8 @@ pub fn unread_query() -> &'static str {
|
||||
|
||||
// `init` describes what should happen when your app started.
|
||||
pub fn init(url: Url, orders: &mut impl Orders<Msg>) -> Model {
|
||||
let version = shared::build_version(bi);
|
||||
info!("Build Info: {}", version);
|
||||
if url.hash().is_none() {
|
||||
orders.request_url(urls::search(unread_query(), 0));
|
||||
} else {
|
||||
@@ -41,12 +43,17 @@ pub fn init(url: Url, orders: &mut impl Orders<Msg>) -> Model {
|
||||
compute_scroll_ratio()
|
||||
}));
|
||||
|
||||
build_info::build_info!(fn bi);
|
||||
Model {
|
||||
context: Context::None,
|
||||
query: "".to_string(),
|
||||
refreshing_state: RefreshingState::None,
|
||||
tags: None,
|
||||
read_completion_ratio: 0.,
|
||||
versions: Version {
|
||||
client: version,
|
||||
server: None,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -335,6 +342,7 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
|
||||
pager: data.search.page_info,
|
||||
selected_threads,
|
||||
};
|
||||
orders.send_msg(Msg::UpdateServerVersion(data.version));
|
||||
}
|
||||
|
||||
Msg::ShowThreadRequest { thread_id } => {
|
||||
@@ -384,6 +392,7 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
|
||||
};
|
||||
}
|
||||
}
|
||||
orders.send_msg(Msg::UpdateServerVersion(data.version));
|
||||
}
|
||||
Msg::ShowThreadResult(bad) => {
|
||||
error!("show_thread_query error: {bad:#?}");
|
||||
@@ -507,6 +516,15 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
|
||||
Msg::SetProgress(ratio) => {
|
||||
model.read_completion_ratio = ratio;
|
||||
}
|
||||
Msg::UpdateServerVersion(version) => {
|
||||
if version != model.versions.client {
|
||||
warn!(
|
||||
"Server ({}) and client ({}) version mismatch",
|
||||
version, model.versions.client
|
||||
);
|
||||
}
|
||||
model.versions.server = Some(version);
|
||||
}
|
||||
}
|
||||
}
|
||||
// `Model` describes our app state.
|
||||
@@ -516,6 +534,13 @@ pub struct Model {
|
||||
pub refreshing_state: RefreshingState,
|
||||
pub tags: Option<Vec<Tag>>,
|
||||
pub read_completion_ratio: f64,
|
||||
pub versions: Version,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Version {
|
||||
pub client: String,
|
||||
pub server: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
@@ -612,4 +637,5 @@ pub enum Msg {
|
||||
CopyToClipboard(String),
|
||||
|
||||
SetProgress(f64),
|
||||
UpdateServerVersion(String),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user