mirror of
https://github.com/storytold/lightcraft.git
synced 2026-11-01 22:17:53 -06:00
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:
@@ -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));
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user