LR-LIB-ALBUM: album.toggleTarget reports toggled: 0 when no photo is left to toggle

The command description lists toggled in every result; the early return left it out, so a client read null instead of 0.
This commit is contained in:
Nathaniel Ledford
2026-10-28 08:16:42 -04:00
parent b90679da15
commit f5e1dd2cbe
2 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -1076,7 +1076,7 @@ pub fn specs() -> Vec<CommandSpec> {
.or_else(|| s.catalog.quick_collection());
let al = existing.and_then(|a| s.catalog.album(a));
return Ok(
json!({"album": al.map(|a| a.id.0), "name": al.map(|a| a.name.clone()), "added": null, "count": al.map_or(0, |a| s.catalog.album_count(a.id)), "skipped": skipped}),
json!({"album": al.map(|a| a.id.0), "name": al.map(|a| a.name.clone()), "added": null, "toggled": 0, "count": al.map_or(0, |a| s.catalog.album_count(a.id)), "skipped": skipped}),
);
}
let target = s.target_album.filter(|a| s.catalog.album(*a).is_some_and(|al| !al.is_smart() && !al.folder));
+2 -2
View File
@@ -49,7 +49,7 @@ fn photos_the_catalog_lacks_reach_no_album() {
// toggling: nothing is made or changed for ids that are gone
let r = s.execute("album.toggleTarget", &json!({"ids": [GONE.0]})).unwrap();
assert!(r["added"].is_null(), "{r}");
assert!(r["added"].is_null() && r["toggled"] == 0, "{r}");
assert!(s.catalog.quick_collection().is_none(), "no Quick Collection for nothing");
assert_eq!(s.undo.len(), undo + 1);
@@ -78,7 +78,7 @@ fn toggling_gone_photos_leaves_the_target_album_and_redo_alone() {
let undo = s.undo.len();
let r = s.execute("album.toggleTarget", &json!({"ids": [GONE.0]})).unwrap();
assert_eq!(r["album"].as_u64(), Some(a.0), "{r}");
assert!(r["added"].is_null(), "{r}");
assert!(r["added"].is_null() && r["toggled"] == 0, "{r}");
assert_eq!(s.catalog.album(a).unwrap().photos, vec![photo]);
assert_eq!((s.undo.len(), s.redo.len()), (undo, 1));
}