diff --git a/Cargo.lock b/Cargo.lock index 45a0f08e8..a7794ade0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1166,7 +1166,7 @@ dependencies = [ [[package]] name = "craft-update" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=04aa1703b32d299e54f78fcde4182f2b393a9116#04aa1703b32d299e54f78fcde4182f2b393a9116" +source = "git+https://github.com/storytold/craft-libs?rev=c5a1cbfb5f9049f9270955caffb5bee5997aebf7#c5a1cbfb5f9049f9270955caffb5bee5997aebf7" dependencies = [ "chrono", "dunce", @@ -4535,7 +4535,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d8fae84b431384b68627d0f9b3b1245fcf9f46f6c0e3dc902e9dce64edd1967" dependencies = [ "libc", - "windows-sys 0.61.2", + "windows-sys 0.45.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index c82ff4cce..eae73bbca 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "92d392cff1 craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "92d392cff132eaf53e13afff77f38b5c11b73aa0" } craft-quit = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "92d392cff132eaf53e13afff77f38b5c11b73aa0" } # craft-update: app-specific pretend versions apply to startup and manual checks. -craft-update = { git = "https://github.com/storytold/craft-libs", version = "=0.1.0", rev = "04aa1703b32d299e54f78fcde4182f2b393a9116", features = ["egui"] } +craft-update = { git = "https://github.com/storytold/craft-libs", version = "=0.1.0", rev = "c5a1cbfb5f9049f9270955caffb5bee5997aebf7", features = ["egui"] } # internal effectcraft-time = { path = "crates/time" } effectcraft-geom = { path = "crates/geom" } diff --git a/crates/ui-egui/src/updates_ui.rs b/crates/ui-egui/src/updates_ui.rs index 3530a9efb..bb8187f56 100644 --- a/crates/ui-egui/src/updates_ui.rs +++ b/crates/ui-egui/src/updates_ui.rs @@ -2,6 +2,8 @@ use crate::EffectcraftApp; +#[cfg(not(target_arch = "wasm32"))] +use craft_update::dialog::{CheckResultDialog, CheckResultResponse}; #[cfg(not(target_arch = "wasm32"))] use craft_update::updater::{Action, Status, Updater}; @@ -14,6 +16,7 @@ pub(crate) struct Runtime { #[cfg(not(target_arch = "wasm32"))] check_requested: bool, pub(crate) manual_window_open: bool, + #[cfg(target_arch = "wasm32")] pub(crate) status_message: Option, } @@ -27,6 +30,7 @@ impl Default for Runtime { #[cfg(not(target_arch = "wasm32"))] check_requested: false, manual_window_open: false, + #[cfg(target_arch = "wasm32")] status_message: None, } } @@ -44,6 +48,7 @@ pub(crate) fn check(app: &mut EffectcraftApp) { #[cfg(not(target_arch = "wasm32"))] { app.updates_rt.check_requested = true; + app.updates_rt.manual_window_open = true; } #[cfg(target_arch = "wasm32")] { @@ -77,19 +82,24 @@ pub(crate) fn show(app: &mut EffectcraftApp, ctx: &egui::Context) { Action::Close => ctx.send_viewport_cmd(egui::ViewportCommand::Close), Action::None => {} } - // The window answers Help ▸ Check for Updates, so it follows the updater's status. let rt = &mut app.updates_rt; - (rt.manual_window_open, rt.status_message) = match rt.updater.status() { - Status::Idle => (false, None), - Status::Checking => (true, None), - Status::UpToDate => ( - true, - Some(crate::i18n::tr("EffectCraft {version} is currently the newest version available.").replace("{version}", env!("CARGO_PKG_VERSION"))), - ), - Status::Failed(e) => (true, Some(crate::i18n::tr("Could not check for updates:\n{error}").replace("{error}", e))), - }; + if rt.manual_window_open { + match CheckResultDialog::new(&crate::UPDATE_APP, env!("CARGO_PKG_VERSION")).show(ctx, rt.updater.status()) { + CheckResultResponse::None => {} + CheckResultResponse::Close => { + rt.manual_window_open = false; + rt.updater.dismiss_status(); + } + CheckResultResponse::CheckAgain => rt.updater.check_now(ctx), + } + // A check that found a release leaves the status idle and the startup prompt takes over. + if matches!(rt.updater.status(), Status::Idle) && !rt.check_requested { + rt.manual_window_open = false; + } + } } + #[cfg(target_arch = "wasm32")] if app.updates_rt.manual_window_open { let mut open = true; let mut close = false; @@ -101,8 +111,6 @@ pub(crate) fn show(app: &mut EffectcraftApp, ctx: &egui::Context) { .show(ctx, |ui| { if let Some(msg) = &app.updates_rt.status_message { ui.label(msg); - } else { - ui.label(crate::i18n::tr("Checking for updates…")); } ui.add_space(8.0); ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { @@ -116,10 +124,4 @@ pub(crate) fn show(app: &mut EffectcraftApp, ctx: &egui::Context) { app.updates_rt.status_message = None; } } - - // Closing the window dismisses the outcome it showed. - #[cfg(not(target_arch = "wasm32"))] - if !app.updates_rt.manual_window_open { - app.updates_rt.updater.dismiss_status(); - } }