Merge remote-tracking branch 'origin/main' into review/pr-1

This commit is contained in:
Brandon Thomas
2026-10-04 01:36:45 -04:00
2 changed files with 25 additions and 1 deletions
+24
View File
@@ -176,3 +176,27 @@ fn stacks_group_collapse_and_replay() {
assert_eq!(s2.catalog.stacks().count(), 1);
let _ = std::fs::remove_dir_all(&dir);
}
#[test]
fn album_source_reports_in_library_state_and_persists_the_view() {
// An album source made `library.state` panic (serde can't put an integer in an internally
// tagged enum) and `view.json` empty, so the view was lost on the next launch.
let dir = temp_dir("album-view");
let mut s = open(&dir);
let id = s.execute("album.create", &json!({"name": "Trip"})).unwrap()["id"].as_u64().unwrap();
s.execute("library.source", &json!({"kind": "album", "id": id})).unwrap();
s.execute("library.sort", &json!({"key": "fileName"})).unwrap();
let st = s.execute("library.state", &json!({})).unwrap();
assert_eq!(st["source"], json!({"kind": "album", "id": id}));
// the reported source is what `library.source` takes
s.execute("library.source", &json!({"kind": "all"})).unwrap();
s.execute("library.source", &st["source"]).unwrap();
assert_eq!(s.source, LibrarySource::Album(lightcraft_catalog::AlbumId(id)));
assert_eq!(s.execute("library.state", &json!({})).unwrap()["source"], json!({"kind": "album", "id": id}));
s.close_library().unwrap();
drop(s);
let s2 = open(&dir);
assert_eq!(s2.source, LibrarySource::Album(lightcraft_catalog::AlbumId(id)));
assert_eq!(serde_json::to_value(s2.sort).unwrap()["key"], "fileName", "the rest of the view is restored too");
let _ = std::fs::remove_dir_all(&dir);
}
+1 -1
View File
@@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize};
/// The "My Photos" source in the left panel.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
#[serde(tag = "kind", rename_all = "camelCase")]
#[serde(tag = "kind", content = "id", rename_all = "camelCase")]
pub enum LibrarySource {
#[default]
All,