mirror of
https://github.com/Dasemu/Synapse.git
synced 2026-11-26 15:26:17 +00:00
feat(app): clean up also offers empty journals, except today's
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a8559fd467
commit
7c898f4fcd
6 files changed
+35
-7
No files matched your search
@@ -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<Vec<LegacyCandidate>> {
|
||||
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 {
|
||||
|
||||
@@ -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());
|
||||
|
||||
Reference in new issue
Block a user