This commit is contained in:
Claude committed 2026-10-11 11:39:25 +00:00
commit 95662cfff5
2 files changed
+38

No files matched your search

+19
View File
@@ -427,6 +427,25 @@ impl LightcraftApp {
// Keep it hidden after release; O / the overlay eye can show it again.
self.ui.mask_overlay = false;
}
if r.is_ok() {
// These commands finish synchronously, so their completion would otherwise
// be invisible once the activity stack is gone. Never show success on error.
let completed = match id {
"library.compact" => Some(format!("✓ {}", i18n::tr("Optimize Library"))),
"library.clearPreviews" => Some(format!("✓ {}", i18n::tr("Clear Preview Cache"))),
"develop.autoSync" => Some(format!(
"{}: {}",
i18n::tr("Auto Sync"),
i18n::tr(if self.session.auto_sync { "On" } else { "Off" })
)),
_ => None,
};
if let Some(message) = completed {
// Menu clicks can arrive before the next frame updates last_time.
let now = self.tasks.repaint.as_ref().map(|ctx| ctx.input(|i| i.time)).unwrap_or(self.last_time);
self.ui.toast = Some((message, now + TOAST_SECONDS, None));
}
}
if r.is_ok() && id == "photo.label" {
let label = params.get("label").and_then(Value::as_str).and_then(lightcraft_catalog::ColorLabel::parse);
let text = match label {
+19
View File
@@ -393,3 +393,22 @@ fn rows_added_later_grow_the_stack() {
assert!(stack.contains_rect(r), "row {} at {r:?} is cut off by the stack at {stack:?}", g.id());
}
}
#[test]
fn immediate_library_commands_and_auto_sync_show_completion() {
let mut h = demo();
assert!(h.app.run("library.clearPreviews", json!({})).is_ok());
assert_eq!(h.app.ui.toast.as_ref().map(|t| t.0.as_str()), Some("✓ Clear Preview Cache"));
assert_eq!(h.app.run("develop.autoSync", json!({"on": true})).unwrap()["on"], true);
assert_eq!(h.app.ui.toast.as_ref().map(|t| t.0.as_str()), Some("Auto Sync: On"));
assert_eq!(h.app.run("develop.autoSync", json!({"on": false})).unwrap()["on"], false);
assert_eq!(h.app.ui.toast.as_ref().map(|t| t.0.as_str()), Some("Auto Sync: Off"));
// This demo has no on-disk library to optimize. A failed command must not
// report completion (or accidentally keep its preceding success toast).
h.app.ui.toast = None;
assert!(h.app.run("library.compact", json!({})).is_err());
assert!(h.app.ui.toast.is_none());
}