mirror of
https://github.com/storytold/effectcraft.git
synced 2026-11-16 15:22:43 +00:00
Merge pull request #3343 from dotCooCoo/fix/update-outcome-at-start
Updates: the first start after an update shows how it ended
This commit is contained in:
2 files changed
+33
-4
No files matched your search
@@ -293,6 +293,29 @@ fn the_close_guard_answers_a_close_request_without_a_pass() {
|
||||
assert_eq!(app.ui_passes(), 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
fn the_update_result_dialog_shows_every_status_but_idle() {
|
||||
use craft_update::updater::Status;
|
||||
let shown = [
|
||||
Status::Checking,
|
||||
Status::UpToDate,
|
||||
Status::Failed("offline".into()),
|
||||
Status::Installing,
|
||||
Status::Ready,
|
||||
Status::Managed,
|
||||
Status::Updated("1.2.3".into()),
|
||||
Status::InstallFailed("access denied".into()),
|
||||
];
|
||||
for status in &shown {
|
||||
assert!(updates_ui::result_window_open(false, status, false), "{status:?} opens the dialog without a requested check");
|
||||
}
|
||||
assert!(!updates_ui::result_window_open(false, &Status::Idle, false));
|
||||
assert!(!updates_ui::result_window_open(true, &Status::Idle, false), "a check that found a release closes it");
|
||||
assert!(updates_ui::result_window_open(true, &Status::Idle, true), "a queued check keeps it open");
|
||||
assert!(!updates_ui::result_window_open(false, &Status::Idle, true), "a queued check does not open it");
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- screenshots
|
||||
|
||||
fn screenshot_request(app: &mut EffectcraftApp, ctx: &egui::Context, path: Option<&str>, target: ShotTarget) -> std::sync::mpsc::Receiver<serde_json::Value> {
|
||||
|
||||
@@ -92,6 +92,15 @@ pub(crate) fn tick(app: &mut EffectcraftApp, ctx: &egui::Context) {
|
||||
let _ = (app, ctx);
|
||||
}
|
||||
|
||||
/// Whether the check result dialog shows this frame. It answers Help ▸ Check for Updates until the
|
||||
/// requested check ends, and it shows whenever the status is not idle: at the first start after an
|
||||
/// update, the check at start leaves `Updated` or `InstallFailed`. A check that finds a release
|
||||
/// leaves the status idle and the startup prompt takes over, so the dialog closes then.
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub(crate) fn result_window_open(open: bool, status: &Status, check_requested: bool) -> bool {
|
||||
!matches!(status, Status::Idle) || (open && check_requested)
|
||||
}
|
||||
|
||||
pub(crate) fn show(app: &mut EffectcraftApp, ctx: &egui::Context) {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
{
|
||||
@@ -103,6 +112,7 @@ pub(crate) fn show(app: &mut EffectcraftApp, ctx: &egui::Context) {
|
||||
Action::None => {}
|
||||
}
|
||||
let rt = &mut app.updates_rt;
|
||||
rt.manual_window_open = result_window_open(rt.manual_window_open, rt.updater.status(), rt.check_requested);
|
||||
if rt.manual_window_open {
|
||||
match CheckResultDialog::new(&crate::UPDATE_APP, env!("CARGO_PKG_VERSION")).show(ctx, rt.updater.status()) {
|
||||
CheckResultResponse::None => {}
|
||||
@@ -113,10 +123,6 @@ pub(crate) fn show(app: &mut EffectcraftApp, ctx: &egui::Context) {
|
||||
CheckResultResponse::CheckAgain => rt.updater.check_now(ctx),
|
||||
CheckResultResponse::RestartToUpdate => restart_to_update(rt, ctx, clean),
|
||||
}
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user