mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-11 09:33:57 +00:00
craft-update: an offer after a failed update clears the failure status
Updater::offer opens a prompt that carries the failed update's reason, and now sets the status to Idle, as a check that finds a release does. An app that shows CheckResultDialog while the status is not Idle no longer shows the failure card and the prompt at once.
This commit is contained in:
@@ -313,10 +313,12 @@ impl Updater {
|
||||
}
|
||||
|
||||
/// Opens the startup prompt for a release the app found itself. After a failed update the
|
||||
/// prompt says why it failed, like the one a check opens.
|
||||
/// prompt says why it failed, like the one a check opens. Opening the prompt sets
|
||||
/// [`Self::status`] to [`Status::Idle`].
|
||||
pub fn offer(&mut self, release: Release) {
|
||||
if self.install.is_none() && !self.installed && !self.read_choice() {
|
||||
self.open_offer(release);
|
||||
self.status = Status::Idle;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1503,6 +1505,7 @@ mod tests {
|
||||
assert_eq!(u.status(), &Status::InstallFailed("disk full".into()));
|
||||
u.offer(newer());
|
||||
assert_eq!(u.prompt.as_ref().and_then(StartupPrompt::message).as_deref(), Some("The update could not be installed: disk full"));
|
||||
assert_eq!(u.status(), &Status::Idle, "the prompt carries the reason");
|
||||
u.prompt = None;
|
||||
u.offer(newer());
|
||||
assert_eq!(u.prompt.as_ref().and_then(StartupPrompt::message), None, "the reason is shown once");
|
||||
|
||||
Reference in New Issue
Block a user