diff --git a/app/lib/src/rust/api/graph.dart b/app/lib/src/rust/api/graph.dart index 3c49ca1..dd9383e 100644 --- a/app/lib/src/rust/api/graph.dart +++ b/app/lib/src/rust/api/graph.dart @@ -100,7 +100,7 @@ abstract class SynapseGraph implements RustOpaqueInterface { /// Pages worth cleaning up: leftovers of Logseq (its built-ins and pages with /// `type:: system`) and empty pages (no text in any block, not a hub, no type, tags or - /// description). Of the Logseq ones only the organisational files (`contents`, `card`, + /// description), journals included except today's. Of the Logseq ones only the organisational files (`contents`, `card`, /// `favorites`, `hls__*`) and empty pages are preselected, and never a hub: a built-in /// title such as `todo` may hold real content. Empty pages are all preselected. Future> legacyCandidates(); diff --git a/app/lib/src/rust/frb_generated.dart b/app/lib/src/rust/frb_generated.dart index f605c8a..c185cf0 100644 --- a/app/lib/src/rust/frb_generated.dart +++ b/app/lib/src/rust/frb_generated.dart @@ -5292,7 +5292,7 @@ class SynapseGraphImpl extends RustOpaque implements SynapseGraph { /// Pages worth cleaning up: leftovers of Logseq (its built-ins and pages with /// `type:: system`) and empty pages (no text in any block, not a hub, no type, tags or - /// description). Of the Logseq ones only the organisational files (`contents`, `card`, + /// description), journals included except today's. Of the Logseq ones only the organisational files (`contents`, `card`, /// `favorites`, `hls__*`) and empty pages are preselected, and never a hub: a built-in /// title such as `todo` may hold real content. Empty pages are all preselected. Future> legacyCandidates() => RustLib.instance.api diff --git a/app/lib/src/views/all_pages_view.dart b/app/lib/src/views/all_pages_view.dart index 918155e..36e3dfc 100644 --- a/app/lib/src/views/all_pages_view.dart +++ b/app/lib/src/views/all_pages_view.dart @@ -76,7 +76,13 @@ class _AllPagesViewState extends State { ); if (removed == null || removed.isEmpty) return; await app.queue.run(() => app.backend.purgePages(removed)); - app.recent.removeWhere((p) => removed.contains(p.id)); + app.pagesDeleted( + removed, + titles: [ + for (final c in candidates) + if (removed.contains(c.id)) c.title, + ], + ); app.reload(); } diff --git a/crates/synapse-ffi/src/api/structure.rs b/crates/synapse-ffi/src/api/structure.rs index e0eff1c..38d4e24 100644 --- a/crates/synapse-ffi/src/api/structure.rs +++ b/crates/synapse-ffi/src/api/structure.rs @@ -206,13 +206,18 @@ impl SynapseGraph { /// Pages worth cleaning up: leftovers of Logseq (its built-ins and pages with /// `type:: system`) and empty pages (no text in any block, not a hub, no type, tags or - /// description). Of the Logseq ones only the organisational files (`contents`, `card`, + /// description), journals included except today's. Of the Logseq ones only the organisational files (`contents`, `card`, /// `favorites`, `hls__*`) and empty pages are preselected, and never a hub: a built-in /// title such as `todo` may hold real content. Empty pages are all preselected. pub fn legacy_candidates(&self) -> Result> { let g = self.lock(); let mut out = Vec::new(); - for p in g.list_pages(false, u32::MAX, 0)? { + let today = g.today(); + for p in g.list_pages(true, u32::MAX, 0)? { + // Today's journal is where new notes land: never offered, even when blank. + if p.journal_date == Some(today) { + continue; + } let key = title_key(&p.title); let tree = g.page_tree(p.id)?; let blocks = tree.len() as u32; @@ -222,7 +227,12 @@ impl SynapseGraph { && p.page_type().is_none() && p.tags.is_empty() && p.description.trim().is_empty(); - let reason = if is_legacy_page(&p.title) { + let reason = if p.is_journal() { + if !empty { + continue; + } + "Empty journal" + } else if is_legacy_page(&p.title) { if key.starts_with("hls__") { "Logseq PDF highlights" } else { diff --git a/crates/synapse-ffi/tests/api.rs b/crates/synapse-ffi/tests/api.rs index 7225d39..467cfbe 100644 --- a/crates/synapse-ffi/tests/api.rs +++ b/crates/synapse-ffi/tests/api.rs @@ -365,6 +365,11 @@ fn legacy_candidates_and_purge() { page_with(&g, "contents", &["- x"]); page_with(&g, "now", &[]); page_with(&g, "Blank", &["", " "]); + let old_day = g.journal("2020-01-02".into()).unwrap().page.id; + let full_day = g.journal("2020-01-03".into()).unwrap().page.id; + g.insert_block(full_day, place(PlaceKind::LastChildOf, None), "x".into()) + .unwrap(); + g.journals(None, 1).unwrap(); // creates today's journal, empty let (typed, _) = page_with(&g, "Typed", &[]); g.set_page_type(typed, Some("persona".into())).unwrap(); g.create_hub("later".into(), String::new()).unwrap(); @@ -395,6 +400,13 @@ fn legacy_candidates_and_purge() { assert_eq!(by("Blank").reason, "Empty"); assert!(by("Blank").preselected, "only blank blocks"); assert!(c.iter().all(|x| x.title != "Typed"), "a type is content"); + let journals: Vec<_> = c.iter().filter(|x| x.reason == "Empty journal").collect(); + assert_eq!( + journals.len(), + 1, + "only the blank past journal, not today's" + ); + assert!(journals[0].id == old_day && journals[0].preselected); // A bad id rejects the call before anything is deleted. assert!(g.purge_pages(vec![todo.clone(), "nope".into()]).is_err()); diff --git a/docs/app.md b/docs/app.md index 46af9fd..2ce8cbb 100644 --- a/docs/app.md +++ b/docs/app.md @@ -174,7 +174,7 @@ Both are plain names with no page, shown as one row of pills under the title. - Every page's `⋯` menu (notes and hubs) ends with "Delete page…": the same confirmation as All pages; tabs showing it step back (or fall back to Journals) and recents drop it. - All pages ▸ "Clean up": dialog listing empty pages (no text in any block, not a hub, no - type, tags or description; all preselected) and legacy Logseq pages (`contents`, + type, tags or description; journals too, except today's; all preselected) and legacy Logseq pages (`contents`, `hls__...`, pages with `type:: system`, ...) with checkboxes and "Select all/none"; "Delete (n)" removes only the checked ones and their blocks.