LRC-LIB-KEYWORDS: dropping photos on a keyword counts those that get it

The toast said every dropped photo got the keyword, those that had it
already included. It now counts the photos that didn't have it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Nathaniel LedfordandClaude Opus 5.5 committed 2026-10-09 15:04:02 -04:00
1 parent 334868b73a
commit decebccb89
2 files changed
+19 -1

No files matched your search

+8 -1
View File
@@ -285,7 +285,14 @@ fn drop_target(app: &mut LightcraftApp, ui: &mut egui::Ui, rect: Rect, path: &st
} else if let Some(ids) = app.ui.dragging_photos.clone() {
outline(ui);
if released {
let n = ids.len();
// only the photos that didn't have it get it
let lacking = |id: &u64| {
app.session
.catalog
.photo(PhotoId(*id))
.is_some_and(|p| !p.meta.keywords.iter().any(|k| same(&lightcraft_catalog::keywords::clean(k), path)))
};
let n = ids.iter().filter(|id| lacking(id)).count();
app.ui.dragging_photos = None;
match app.run("photo.setMeta", json!({"ids": ids, "addKeywords": [path]})) {
Ok(_) => app.toast(
+11
View File
@@ -417,3 +417,14 @@ fn typed_keywords_go_inside_the_default_parent() {
assert!(k.contains(&want.to_string()), "{want}: {k:?}");
}
}
/// Dropping photos on a keyword says how many got it: one that had it already isn't counted.
#[test]
fn dropping_photos_counts_those_that_get_the_keyword() {
let (mut h, ids) = keywords_panel_at([1400.0, 2400.0]);
run(&mut h, "keyword.create", json!({"name": "Portugal"}));
run(&mut h, "photo.setMeta", json!({"ids": [ids[1]], "addKeywords": ["Portugal"]}));
drag(&mut h, &format!("thumb:{}", ids[0]), "keywordRow:Portugal");
let toast = h.app.ui.toast.clone().map(|t| t.0).unwrap_or_default();
assert!(toast.contains("1 photo") && !toast.contains("2 photos"), "{toast}");
}