From 3d44b69f72ea3bc25e8f85b0ce5a221ea0017df8 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Mon, 18 Jul 2022 03:43:56 +0000 Subject: feat(main.rs): add outdated check --- src/main.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index 77841a9..d04b84a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -79,6 +79,33 @@ Report bugs to https://github.com/gemrest/sydney/issues"#, let mut stdout = std::io::stdout(); + match germ::request::request( + &url::Url::parse("gemini://fuwn.me/api/sydney/version").unwrap(), + ) { + Ok(response) => + if let Some(content) = response.content() { + if content > &String::from(env!("CARGO_PKG_VERSION")) { + app.error = Some(format!( + "Your Sydney version ({}) is outdated. It is recommended that you \ + update to the newest version ({}).", + env!("CARGO_PKG_VERSION"), + content, + )); + } + } else { + app.error = Some( + "Could not check if Sydney has a newer version because the response \ + had no content. Please try again later." + .to_string(), + ); + }, + Err(error) => + app.error = Some(format!( + "Could not check if Sydney has a newer version: {}", + error + )), + } + execute!( stdout, terminal::EnterAlternateScreen, -- cgit v1.2.3