rip out update checking (too unreliable)
This commit is contained in:
+2
-15
@@ -1,7 +1,7 @@
|
||||
use crate::{
|
||||
features,
|
||||
gui::{colours, settings::Settings, tools, ui_ext::UiExt},
|
||||
util::{consts::game::WINDOW_TITLE, meta::Meta, persistent_state::PersistentState, win},
|
||||
util::{consts::game::WINDOW_TITLE, persistent_state::PersistentState, win},
|
||||
};
|
||||
use eframe::egui;
|
||||
use std::time::{Duration, Instant};
|
||||
@@ -36,7 +36,6 @@ impl Default for Flags {
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct App {
|
||||
pub meta: Meta,
|
||||
pub settings: Settings,
|
||||
stage: Stage,
|
||||
pub flags: Flags,
|
||||
@@ -232,21 +231,9 @@ impl App {
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
ui.label(format!(
|
||||
"v{} {}",
|
||||
self.meta.current_version,
|
||||
env!("CARGO_PKG_VERSION"),
|
||||
if cfg!(debug_assertions) { "(dev)" } else { "" }
|
||||
));
|
||||
let button = ui.add_enabled_ui(self.meta.newer_version_available, |ui| {
|
||||
ui.style_mut().spacing.button_padding = egui::Vec2::new(3.0, 0.0);
|
||||
ui.button("⬇")
|
||||
.on_disabled_hover_text("Already up to date.")
|
||||
.on_hover_text(format!(
|
||||
"New version available! ({})",
|
||||
self.meta.latest_release.version
|
||||
))
|
||||
});
|
||||
if button.inner.clicked() {
|
||||
open::that(&self.meta.latest_release.download_url).unwrap();
|
||||
}
|
||||
});
|
||||
});
|
||||
ui.add(egui::Image::new(egui::include_image!(
|
||||
|
||||
+1
-9
@@ -17,11 +17,6 @@ impl App {
|
||||
if ui.button("open storage path").clicked() {
|
||||
open::that_detached(path::APP_STORAGE.as_path()).unwrap();
|
||||
}
|
||||
ui.checkbox(
|
||||
&mut self.meta.newer_version_available,
|
||||
"spoof new version available",
|
||||
)
|
||||
.on_hover_text("(this could already be checked if\nthere actually IS a new version)");
|
||||
ui.scope(|ui| {
|
||||
use windows::Win32::UI::WindowsAndMessaging::{
|
||||
GetForegroundWindow, GetWindowTextW,
|
||||
@@ -42,10 +37,7 @@ impl App {
|
||||
ui.build_menu(&mut self.game_networking.blocked_status);
|
||||
});
|
||||
});
|
||||
if ui
|
||||
.add(egui::Button::new("force refresh theme"))
|
||||
.clicked()
|
||||
{
|
||||
if ui.add(egui::Button::new("force refresh theme")).clicked() {
|
||||
catppuccin_egui::set_theme(ui.ctx(), self.settings.theme.into());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
mod codeberg;
|
||||
pub mod consts;
|
||||
pub mod countdown;
|
||||
pub mod log;
|
||||
pub mod meta;
|
||||
pub mod persistent_state;
|
||||
pub mod win;
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
use semver::Version;
|
||||
use serde::Deserialize;
|
||||
use std::time::Duration;
|
||||
|
||||
const APP_USER_AGENT: &str = concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION"));
|
||||
const CODEBERG_ENDPOINT_ROOT: &str = "https://codeberg.org/api/v1";
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Release {
|
||||
pub version: Version,
|
||||
pub download_url: String,
|
||||
}
|
||||
|
||||
impl Default for Release {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
version: Version::new(0, 0, 0),
|
||||
download_url: String::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct LatestRelease {
|
||||
tag_name: String,
|
||||
assets: Vec<Asset>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct Asset {
|
||||
browser_download_url: String,
|
||||
}
|
||||
|
||||
pub fn get_latest_release() -> Result<Release, Box<dyn std::error::Error>> {
|
||||
let request_url = format!("{CODEBERG_ENDPOINT_ROOT}/repos/futile/gta-tools/releases/latest");
|
||||
let mut response = ureq::get(request_url)
|
||||
.config()
|
||||
.timeout_global(Some(Duration::from_secs(10)))
|
||||
.user_agent(APP_USER_AGENT)
|
||||
.build()
|
||||
.call()?;
|
||||
let body = response.body_mut();
|
||||
let json = body.read_json::<LatestRelease>()?;
|
||||
let tag_name = json.tag_name;
|
||||
let browser_download_url = &json.assets[0].browser_download_url;
|
||||
Ok(Release {
|
||||
version: Version::parse(&tag_name)?,
|
||||
download_url: browser_download_url.to_owned(),
|
||||
})
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
use crate::{util::codeberg, util::log};
|
||||
use semver::Version;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Meta {
|
||||
pub current_version: Version,
|
||||
pub latest_release: codeberg::Release,
|
||||
pub newer_version_available: bool,
|
||||
}
|
||||
|
||||
impl Default for Meta {
|
||||
fn default() -> Self {
|
||||
let current_version = Version::parse(env!("CARGO_PKG_VERSION")).unwrap();
|
||||
let latest_release = codeberg::get_latest_release().unwrap_or_else(|why| {
|
||||
let message = format!("failed to get latest codeberg release:\n{why}");
|
||||
log::log(log::LogLevel::Error, &message);
|
||||
codeberg::Release::default()
|
||||
});
|
||||
let newer_version_available = matches!(
|
||||
¤t_version.cmp_precedence(&latest_release.version),
|
||||
std::cmp::Ordering::Less
|
||||
);
|
||||
Self {
|
||||
current_version,
|
||||
latest_release,
|
||||
newer_version_available,
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user