fix: parse lowercase 'archived' frontmatter field
The frontend writes 'archived: true' (lowercase) via handleUpdateFrontmatter, but the Rust parser only recognized 'Archived' (titlecase). This caused all notes archived from within Laputa to be read back as not archived — they continued appearing in the sidebar and note list after restart. Fix: add alias = "archived" to the serde attribute, matching the pattern already used for 'trashed'/'Trashed'. Regression tests added for both lowercase and titlecase variants.
This commit is contained in:
@@ -108,7 +108,7 @@ struct Frontmatter {
|
||||
owner: Option<String>,
|
||||
#[serde(rename = "Cadence")]
|
||||
cadence: Option<String>,
|
||||
#[serde(rename = "Archived")]
|
||||
#[serde(rename = "Archived", alias = "archived")]
|
||||
archived: Option<bool>,
|
||||
#[serde(rename = "Trashed", alias = "trashed")]
|
||||
trashed: Option<bool>,
|
||||
@@ -1374,6 +1374,28 @@ Company: Acme Corp
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_archived_lowercase_alias() {
|
||||
let dir = TempDir::new().unwrap();
|
||||
let content = "---\narchived: true\n---\n# Old Quarter\n";
|
||||
let entry = parse_test_entry(&dir, "old-quarter.md", content);
|
||||
assert!(
|
||||
entry.archived,
|
||||
"lowercase 'archived' must be parsed via alias (frontend writes lowercase)"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_archived_titlecase() {
|
||||
let dir = TempDir::new().unwrap();
|
||||
let content = "---\nArchived: true\n---\n# Old Quarter\n";
|
||||
let entry = parse_test_entry(&dir, "old-quarter-2.md", content);
|
||||
assert!(
|
||||
entry.archived,
|
||||
"titlecase 'Archived' must also be parsed"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_trashed_false_when_absent() {
|
||||
let dir = TempDir::new().unwrap();
|
||||
|
||||
Reference in New Issue
Block a user