mirror of
https://github.com/Dasemu/Synapse.git
synced 2026-11-26 23:36:20 +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
@@ -100,7 +100,7 @@ abstract class SynapseGraph implements RustOpaqueInterface {
|
|||||||
|
|
||||||
/// Pages worth cleaning up: leftovers of Logseq (its built-ins and pages with
|
/// 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
|
/// `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
|
/// `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.
|
/// title such as `todo` may hold real content. Empty pages are all preselected.
|
||||||
Future<List<LegacyCandidate>> legacyCandidates();
|
Future<List<LegacyCandidate>> legacyCandidates();
|
||||||
|
|||||||
@@ -5292,7 +5292,7 @@ class SynapseGraphImpl extends RustOpaque implements SynapseGraph {
|
|||||||
|
|
||||||
/// Pages worth cleaning up: leftovers of Logseq (its built-ins and pages with
|
/// 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
|
/// `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
|
/// `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.
|
/// title such as `todo` may hold real content. Empty pages are all preselected.
|
||||||
Future<List<LegacyCandidate>> legacyCandidates() => RustLib.instance.api
|
Future<List<LegacyCandidate>> legacyCandidates() => RustLib.instance.api
|
||||||
|
|||||||
@@ -76,7 +76,13 @@ class _AllPagesViewState extends State<AllPagesView> {
|
|||||||
);
|
);
|
||||||
if (removed == null || removed.isEmpty) return;
|
if (removed == null || removed.isEmpty) return;
|
||||||
await app.queue.run(() => app.backend.purgePages(removed));
|
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();
|
app.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -206,13 +206,18 @@ impl SynapseGraph {
|
|||||||
|
|
||||||
/// Pages worth cleaning up: leftovers of Logseq (its built-ins and pages with
|
/// 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
|
/// `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
|
/// `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.
|
/// title such as `todo` may hold real content. Empty pages are all preselected.
|
||||||
pub fn legacy_candidates(&self) -> Result<Vec<LegacyCandidate>> {
|
pub fn legacy_candidates(&self) -> Result<Vec<LegacyCandidate>> {
|
||||||
let g = self.lock();
|
let g = self.lock();
|
||||||
let mut out = Vec::new();
|
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 key = title_key(&p.title);
|
||||||
let tree = g.page_tree(p.id)?;
|
let tree = g.page_tree(p.id)?;
|
||||||
let blocks = tree.len() as u32;
|
let blocks = tree.len() as u32;
|
||||||
@@ -222,7 +227,12 @@ impl SynapseGraph {
|
|||||||
&& p.page_type().is_none()
|
&& p.page_type().is_none()
|
||||||
&& p.tags.is_empty()
|
&& p.tags.is_empty()
|
||||||
&& p.description.trim().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__") {
|
if key.starts_with("hls__") {
|
||||||
"Logseq PDF highlights"
|
"Logseq PDF highlights"
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -365,6 +365,11 @@ fn legacy_candidates_and_purge() {
|
|||||||
page_with(&g, "contents", &["- x"]);
|
page_with(&g, "contents", &["- x"]);
|
||||||
page_with(&g, "now", &[]);
|
page_with(&g, "now", &[]);
|
||||||
page_with(&g, "Blank", &["", " "]);
|
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", &[]);
|
let (typed, _) = page_with(&g, "Typed", &[]);
|
||||||
g.set_page_type(typed, Some("persona".into())).unwrap();
|
g.set_page_type(typed, Some("persona".into())).unwrap();
|
||||||
g.create_hub("later".into(), String::new()).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_eq!(by("Blank").reason, "Empty");
|
||||||
assert!(by("Blank").preselected, "only blank blocks");
|
assert!(by("Blank").preselected, "only blank blocks");
|
||||||
assert!(c.iter().all(|x| x.title != "Typed"), "a type is content");
|
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.
|
// A bad id rejects the call before anything is deleted.
|
||||||
assert!(g.purge_pages(vec![todo.clone(), "nope".into()]).is_err());
|
assert!(g.purge_pages(vec![todo.clone(), "nope".into()]).is_err());
|
||||||
|
|||||||
+1
-1
@@ -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
|
- 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; 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
|
- 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";
|
`hls__...`, pages with `type:: system`, ...) with checkboxes and "Select all/none";
|
||||||
"Delete (n)" removes only the checked ones and their blocks.
|
"Delete (n)" removes only the checked ones and their blocks.
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user