diff --git a/Cargo.lock b/Cargo.lock index 98b181d66..c0df56599 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1138,7 +1138,7 @@ dependencies = [ [[package]] name = "craft-update" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c5a1cbfb5f9049f9270955caffb5bee5997aebf7#c5a1cbfb5f9049f9270955caffb5bee5997aebf7" +source = "git+https://github.com/dotCooCoo/craft-libs?rev=c7c84230631cbc01ee928f0a0e0d838b1ed612ae#c7c84230631cbc01ee928f0a0e0d838b1ed612ae" dependencies = [ "chrono", "dunce", @@ -7945,7 +7945,6 @@ dependencies = [ "nix", "typed-path", "windows-sys 0.61.2", - "zopfli", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index dbf070673..47b925a23 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,7 @@ craft-keymap = { git = "https://github.com/storytold/craft-libs", rev = "92d392c # Separations, ink coverage and the ink manager; same revision as craft-pdf and the krilla patch. craft-prepress = { git = "https://github.com/storytold/craft-libs", rev = "92d392cff132eaf53e13afff77f38b5c11b73aa0", version = "=0.1.0", features = ["flatten"] } # 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 = "c5a1cbfb5f9049f9270955caffb5bee5997aebf7", features = ["egui"] } +craft-update = { git = "https://github.com/dotCooCoo/craft-libs", version = "=0.1.0", rev = "c7c84230631cbc01ee928f0a0e0d838b1ed612ae", features = ["egui"] } # internal designcraft-geom = { path = "crates/geom" } designcraft-color = { path = "crates/color" } diff --git a/crates/ui-egui/src/updates_ui.rs b/crates/ui-egui/src/updates_ui.rs index 24a056247..53bae1502 100644 --- a/crates/ui-egui/src/updates_ui.rs +++ b/crates/ui-egui/src/updates_ui.rs @@ -4,7 +4,7 @@ use serde_json::Value; use crate::DesignApp; -#[cfg(all(not(target_arch = "wasm32"), test))] +#[cfg(not(target_arch = "wasm32"))] use craft_update::updater::Status; #[cfg(not(target_arch = "wasm32"))] use craft_update::updater::{Action, Updater}; @@ -84,10 +84,18 @@ pub(crate) fn tick(app: &mut DesignApp, ctx: &egui::Context) { let _ = (app, ctx); } +/// Whether the check result window shows: for every status but idle (a requested check, and the +/// first start after an update, which reports that it installed or why it failed), and never over +/// the startup prompt. +#[cfg(not(target_arch = "wasm32"))] +fn result_window_shows(status: &Status, prompt_open: bool) -> bool { + !prompt_open && !matches!(status, Status::Idle) +} + pub(crate) fn show(app: &mut DesignApp, ctx: &egui::Context) { #[cfg(not(target_arch = "wasm32"))] { - // The restart helper is scheduled before the app closes, so no update starts over unsaved work. + // The updater asks to close only when no document has unsaved changes; the install starts when the app exits. let clean = !app.session.documents().iter().any(|d| d.is_dirty()); match app.updates_rt.updater.show_if(ctx, clean) { Action::OpenUrl(url) => ctx.open_url(egui::OpenUrl::new_tab(url)), @@ -95,11 +103,15 @@ pub(crate) fn show(app: &mut DesignApp, ctx: &egui::Context) { Action::None => {} } // Help ▸ Check for Updates answers in the shared dialog, which follows the updater's status. - let dialog = CheckResultDialog::new(&crate::UPDATE_APP, env!("CARGO_PKG_VERSION")); - match dialog.show(ctx, app.updates_rt.updater.status()) { - CheckResultResponse::None => {} - CheckResultResponse::Close => app.updates_rt.updater.dismiss_status(), - CheckResultResponse::CheckAgain => app.updates_rt.check_requested = true, + if result_window_shows(app.updates_rt.updater.status(), app.updates_rt.updater.prompt_open()) { + let dialog = CheckResultDialog::new(&crate::UPDATE_APP, env!("CARGO_PKG_VERSION")); + match dialog.show(ctx, app.updates_rt.updater.status()) { + CheckResultResponse::None => {} + CheckResultResponse::Close => app.updates_rt.updater.dismiss_status(), + CheckResultResponse::CheckAgain => app.updates_rt.check_requested = true, + // The next `show_if` asks the window to close once no document has unsaved changes. + CheckResultResponse::RestartToUpdate => app.updates_rt.updater.restart_to_update(), + } } } @@ -165,4 +177,24 @@ mod tests { output.textures_delta.clear(); assert!(app.updates_rt.updater.prompt_open()); } + + #[test] + #[cfg(not(target_arch = "wasm32"))] + fn result_window_shows_every_status_but_idle() { + let shown = [ + Status::Checking, + Status::UpToDate, + Status::Failed("no network".into()), + Status::Installing, + Status::Ready, + Status::Managed, + Status::Updated("0.2.0".into()), + Status::InstallFailed("disk full".into()), + ]; + for status in &shown { + assert!(result_window_shows(status, false), "{status:?}"); + assert!(!result_window_shows(status, true), "{status:?} over the prompt"); + } + assert!(!result_window_shows(&Status::Idle, false)); + } }