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

This commit is contained in:
Nathaniel Ledford
2026-10-27 06:45:10 -04:00
parent 0320e8774c
commit f912d18dea
2 changed files with 24 additions and 2 deletions
+3 -2
View File
@@ -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}))
+21
View File
@@ -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");