Skip to content

LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust

fix(updates): address review feedback

Dylan M. Tayloree487850909a
diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs
index 71c2cef13..be1a9e879 100644
--- a/crates/ui-egui/src/lib.rs
+++ b/crates/ui-egui/src/lib.rs
@@ -2127,7 +2127,7 @@ impl LightcraftApp {
// Recent-library checks and launch-list keys read focus/time/keys: they belong to the UI
// phase, not the hidden-capable `logic` tick (plan §4.5 / migration input contract).
panels::library_problem::logic(self, ctx);
- if self.fonts_ready {
+ if self.fonts_ready && !updates_ui::blocks_input(self) {
shortcuts::handle(self, ctx);
}
}
diff --git a/crates/ui-egui/src/updates_ui.rs b/crates/ui-egui/src/updates_ui.rs
index 6ef3a97bc..92f421e45 100644
--- a/crates/ui-egui/src/updates_ui.rs
+++ b/crates/ui-egui/src/updates_ui.rs
@@ -15,6 +15,9 @@ pub(crate) struct Runtime {
startup_check: bool,
#[cfg(not(target_arch = "wasm32"))]
check_requested: bool,
+ /// The context of the last frame, to wake the UI when a check is queued from a menu callback.
+ #[cfg(not(target_arch = "wasm32"))]
+ repaint: Option<egui::Context>,
pub(crate) manual_window_open: bool,
pub(crate) status_message: Option<String>,
}
@@ -28,6 +31,8 @@ impl Default for Runtime {
startup_check: false,
#[cfg(not(target_arch = "wasm32"))]
check_requested: false,
+ #[cfg(not(target_arch = "wasm32"))]
+ repaint: None,
manual_window_open: false,
status_message: None,
}
@@ -42,10 +47,26 @@ impl LightcraftApp {
}
}
+/// The update prompt owns the keyboard while it is open: shortcuts must not reach the library behind it.
+pub(crate) fn blocks_input(app: &LightcraftApp) -> bool {
+ #[cfg(not(target_arch = "wasm32"))]
+ {
+ app.updates_rt.updater.prompt_open()
+ }
+ #[cfg(target_arch = "wasm32")]
+ {
+ let _ = app;
+ false
+ }
+}
+
pub(crate) fn check(app: &mut LightcraftApp) -> Result<Value, String> {
#[cfg(not(target_arch = "wasm32"))]
{
app.updates_rt.check_requested = true;
+ if let Some(ctx) = &app.updates_rt.repaint {
+ ctx.request_repaint();
+ }
Ok(Value::Null)
}
#[cfg(target_arch = "wasm32")]
@@ -60,6 +81,7 @@ pub(crate) fn tick(app: &mut LightcraftApp, ctx: &egui::Context) {
#[cfg(not(target_arch = "wasm32"))]
{
let rt = &mut app.updates_rt;
+ rt.repaint = Some(ctx.clone());
if std::mem::take(&mut rt.check_requested) {
rt.updater.check_now(ctx);
} else if rt.startup_check {