diff --git a/crates/update/src/updater.rs b/crates/update/src/updater.rs index 48d46e31..d90976de 100644 --- a/crates/update/src/updater.rs +++ b/crates/update/src/updater.rs @@ -91,15 +91,22 @@ impl Updater { self.begin(ctx, true); } + /// Opens the startup prompt for a release the app found itself. + pub fn offer(&mut self, release: Release) { + if self.install.is_none() { + self.prompt = Some(StartupPrompt::new(self.app, release, self.version.clone())); + } + } + pub fn status(&self) -> &Status { &self.status } - /// Dismisses the outcome of a requested check. + /// Dismisses the outcome of a requested check. One still running carries on, and reports + /// like the check at start (a prompt if there is a release, otherwise nothing). pub fn dismiss_status(&mut self) { - if self.check.is_none() { - self.status = Status::Idle; - } + self.requested = false; + self.status = Status::Idle; } /// Whether the startup prompt is showing. @@ -303,6 +310,15 @@ mod tests { assert_eq!(u.status(), &Status::Idle); } + #[test] + fn dismissing_a_running_check_keeps_it_quiet() { + let (ctx, mut u) = (egui::Context::default(), updater(Ok(None))); + u.check_now(&ctx); + u.dismiss_status(); + settle(&mut u, &ctx); + assert_eq!(u.status(), &Status::Idle); + } + #[test] fn a_requested_check_reports_a_failure_but_the_startup_check_stays_quiet() { let ctx = egui::Context::default();