mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-11-07 03:01:55 +00:00
M14: decide the update check at start once, on the first frame (#5737)
Review of #5758: with the preference off, the startup request stayed pending, so turning the preference on later in the session sent a network request at once. The request is now consumed on the first poll whatever the preference says, and a later change waits for the next start.
This commit is contained in:
3 files changed
+16
-4
No files matched your search
@@ -74,11 +74,12 @@ impl PdfCraftApp {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
{
|
||||
let Some(ctx) = self.ctx.clone() else { return };
|
||||
let at_start = self.update_check_at_start;
|
||||
// Settled on the first frame: a preference turned on later waits for the next start.
|
||||
let at_start = std::mem::take(&mut self.updates.startup_check) && self.update_check_at_start;
|
||||
let updates = &mut self.updates;
|
||||
if std::mem::take(&mut updates.check_requested) {
|
||||
updates.updater.check_now(&ctx);
|
||||
} else if updates.startup_check && at_start {
|
||||
} else if at_start {
|
||||
updates.updater.check_at_start(&ctx);
|
||||
}
|
||||
updates.updater.tick(&ctx);
|
||||
|
||||
@@ -155,6 +155,17 @@ fn the_preference_keeps_the_check_at_start_from_reaching_the_network() {
|
||||
h.get_by_label_contains("PdfCraft 99.0.0 is available");
|
||||
}
|
||||
|
||||
/// The setting is about starting: turning it on asks nothing until the next start.
|
||||
#[test]
|
||||
fn turning_the_check_at_start_on_waits_for_the_next_start() {
|
||||
use std::sync::atomic::Ordering::SeqCst;
|
||||
let (mut h, calls) = started_with(r#"{"update_check_at_start": false}"#);
|
||||
h.run_steps(3);
|
||||
h.state_mut().set_option("update_check_at_start", "true").unwrap();
|
||||
run_until_asked(&mut h, &calls, std::time::Duration::from_millis(500));
|
||||
assert_eq!(calls.load(SeqCst), 0, "nothing is asked this session");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn preferences_turn_the_check_at_start_off() {
|
||||
let (mut h, _calls) = started_with(r#"{"update_check_at_start": true}"#);
|
||||
|
||||
@@ -1778,8 +1778,8 @@ milestone = "M3"
|
||||
status = "partial"
|
||||
commands = ["help.check_updates"]
|
||||
tools = []
|
||||
evidence = ["crates/ui-egui/tests/it/updates.rs::a_newer_release_is_offered_for_download", "crates/ui-egui/tests/it/updates.rs::an_up_to_date_or_failed_check_says_so", "crates/ui-egui/tests/it/updates.rs::the_check_at_start_offers_the_prompt_and_later_dismisses_it", "crates/ui-egui/tests/it/updates.rs::nothing_is_asked_until_the_user_checks", "crates/ui-egui/tests/it/updates.rs::the_preference_keeps_the_check_at_start_from_reaching_the_network", "crates/ui-egui/tests/it/updates.rs::settings_from_the_old_opt_in_leave_the_check_at_start_on"]
|
||||
notes = "asks GitHub Releases through craft-update at start (desktop app only) and on request, offers the release page, and updates and restarts in place where the install type allows it; an install waits while documents are unsaved; Preferences ▸ Check for updates when PdfCraft starts (update_check_at_start, on by default) turns the check at start off, leaving only the request from the Help menu"
|
||||
evidence = ["crates/ui-egui/tests/it/updates.rs::a_newer_release_is_offered_for_download", "crates/ui-egui/tests/it/updates.rs::an_up_to_date_or_failed_check_says_so", "crates/ui-egui/tests/it/updates.rs::the_check_at_start_offers_the_prompt_and_later_dismisses_it", "crates/ui-egui/tests/it/updates.rs::nothing_is_asked_until_the_user_checks", "crates/ui-egui/tests/it/updates.rs::turning_the_check_at_start_on_waits_for_the_next_start", "crates/ui-egui/tests/it/updates.rs::the_preference_keeps_the_check_at_start_from_reaching_the_network", "crates/ui-egui/tests/it/updates.rs::settings_from_the_old_opt_in_leave_the_check_at_start_on"]
|
||||
notes = "asks GitHub Releases through craft-update at start (desktop app only) and on request, offers the release page, and updates and restarts in place where the install type allows it; an install waits while documents are unsaved; Preferences ▸ Check for updates when PdfCraft starts (update_check_at_start, on by default) turns the check at start off, leaving only the request from the Help menu; turning it on takes effect at the next start"
|
||||
|
||||
[[feature]]
|
||||
id = "view.single-key-accelerators"
|
||||
|
||||
Reference in new issue
Block a user