Skip to content

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

LRC-LIB-LIBFOLDERS: Don't ask again is kept only when a photo moved

Nathaniel Ledfordf912d18dea9a
diff --git a/crates/ui-egui/src/dialogs/confirm.rs b/crates/ui-egui/src/dialogs/confirm.rs
index 3b13bedbd..848ecf326 100644
--- a/crates/ui-egui/src/dialogs/confirm.rs
+++ b/crates/ui-egui/src/dialogs/confirm.rs
@@ -213,8 +213,9 @@ pub fn confirm_dialog(app: &mut LightcraftApp, dlg: &Dialog) -> Result<serde_jso
return Err(crate::i18n::tr("Another library was opened since the photos were dropped: nothing was moved").to_string());
}
let moved = crate::panels::left::move_photos(app, Some(ids), folder)?;
- // only a move that began turns the question off: one refused leaves it as it was
- if *dont_ask {
+ // only a move that began turns the question off: one refused, or that found the photos there already,
+ // leaves it as it was
+ if *dont_ask && moved > 0 {
app.ui.settings.ask_before_move = false;
}
Ok(json!({"moved": moved}))
diff --git a/crates/ui-egui/src/tests/folder_drop.rs b/crates/ui-egui/src/tests/folder_drop.rs
index c45c37640..438e035d6 100644
--- a/crates/ui-egui/src/tests/folder_drop.rs
+++ b/crates/ui-egui/src/tests/folder_drop.rs
@@ -347,6 +347,27 @@ fn dont_ask_again_is_kept_only_when_the_move_began() {
let _ = std::fs::remove_dir_all(&root);
}
+/// A confirmation that finds the photos in the folder already (they were moved there while the question was
+/// open, or a folder synchronization relinked them) moves nothing, so it doesn't turn the question off either.
+#[test]
+fn dont_ask_again_is_kept_only_when_a_photo_moved() {
+ let (root, trip, home) = folders("dont-ask-already");
+ let mut h = app(&[(trip.join("beach.png"), false), (home.join("garden.png"), false)]);
+ click(&mut h, &format!("libraryFolderToggle:{}", folder_key(&root)));
+ let target = folder_row(&h, &home).unwrap();
+ let beach = id_of(&h, "beach.png");
+ drop_beach(&mut h, beach, target);
+ click(&mut h, "check:moveDontAsk");
+ assert!(matches!(h.app.ui.dialog, Some(crate::state::Dialog::MovePhotos { dont_ask: true, .. })), "ticked");
+ // the photo gets there some other way while the question is open
+ h.app.run("photo.moveToFolder", json!({"folder": home.to_string_lossy(), "ids": [beach]})).unwrap();
+ assert!(home.join("beach.png").is_file());
+ click(&mut h, "button:dialogOk");
+ assert!(h.app.ui.dialog.is_none());
+ assert!(h.app.ui.settings.ask_before_move, "nothing moved: the question stays on");
+ let _ = std::fs::remove_dir_all(&root);
+}
+
#[test]
fn a_question_left_open_while_another_library_opens_moves_nothing() {
let (root, trip, home) = folders("other-library");