mirror of
https://github.com/Dasemu/Synapse.git
synced 2026-11-26 15:26:17 +00:00
feat(app): clean up also offers every empty page, with select all/none
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ad62a7d258
commit
141e1a20d0
6 files changed
+59
-23
No files matched your search
@@ -98,10 +98,11 @@ abstract class SynapseGraph implements RustOpaqueInterface {
|
||||
/// journal); otherwise at the newest journal strictly before `before`.
|
||||
Future<List<PageData>> journals({String? before, required int limit});
|
||||
|
||||
/// Pages that are probably leftovers of Logseq: its built-ins and pages with
|
||||
/// `type:: system`. 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.
|
||||
/// 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`,
|
||||
/// `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<List<LegacyCandidate>> legacyCandidates();
|
||||
|
||||
/// Pages ordered by last update, most recent first.
|
||||
|
||||
@@ -5290,10 +5290,11 @@ class SynapseGraphImpl extends RustOpaque implements SynapseGraph {
|
||||
limit: limit,
|
||||
);
|
||||
|
||||
/// Pages that are probably leftovers of Logseq: its built-ins and pages with
|
||||
/// `type:: system`. 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.
|
||||
/// 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`,
|
||||
/// `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<List<LegacyCandidate>> legacyCandidates() => RustLib.instance.api
|
||||
.crateApiGraphSynapseGraphLegacyCandidates(that: this);
|
||||
|
||||
|
||||
@@ -374,21 +374,43 @@ class _CleanupDialogState extends State<CleanupDialog> {
|
||||
final colors = context.colors;
|
||||
final items = widget.candidates;
|
||||
return AlertDialog(
|
||||
title: const Text('Remove legacy Logseq pages'),
|
||||
title: const Text('Clean up pages'),
|
||||
content: SizedBox(
|
||||
width: 460,
|
||||
child: items.isEmpty
|
||||
? Text(
|
||||
'No legacy pages found.',
|
||||
'Nothing to clean up.',
|
||||
style: TextStyle(color: colors.muted),
|
||||
)
|
||||
: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'This deletes the selected pages and their blocks.',
|
||||
style: TextStyle(fontSize: 13, color: colors.muted),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
'Empty pages and Logseq leftovers. This deletes the '
|
||||
'selected pages and their blocks.',
|
||||
style: TextStyle(fontSize: 13, color: colors.muted),
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
key: const Key('cleanup-toggle-all'),
|
||||
onPressed: () => setState(() {
|
||||
if (_checked.length == items.length) {
|
||||
_checked.clear();
|
||||
} else {
|
||||
_checked.addAll([for (final c in items) c.id]);
|
||||
}
|
||||
}),
|
||||
child: Text(
|
||||
_checked.length == items.length
|
||||
? 'Select none'
|
||||
: 'Select all',
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Flexible(
|
||||
|
||||
@@ -515,7 +515,7 @@ void main() {
|
||||
await pump(tester, b, home: const Scaffold(body: AllPagesView()));
|
||||
await tester.tap(find.text('Clean up'));
|
||||
await settle(tester);
|
||||
expect(find.text('Remove legacy Logseq pages'), findsOneWidget);
|
||||
expect(find.text('Clean up pages'), findsOneWidget);
|
||||
expect(find.text('Delete (2)'), findsOneWidget);
|
||||
// Uncheck "card".
|
||||
await tester.tap(
|
||||
@@ -538,7 +538,7 @@ void main() {
|
||||
await pump(tester, demo(), home: const Scaffold(body: AllPagesView()));
|
||||
await tester.tap(find.text('Clean up'));
|
||||
await settle(tester);
|
||||
expect(find.text('No legacy pages found.'), findsOneWidget);
|
||||
expect(find.text('Nothing to clean up.'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -204,15 +204,24 @@ impl SynapseGraph {
|
||||
))
|
||||
}
|
||||
|
||||
/// Pages that are probably leftovers of Logseq: its built-ins and pages with
|
||||
/// `type:: system`. 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.
|
||||
/// 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`,
|
||||
/// `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 key = title_key(&p.title);
|
||||
let tree = g.page_tree(p.id)?;
|
||||
let blocks = tree.len() as u32;
|
||||
let blank = tree.iter().all(|(_, b)| b.content.trim().is_empty());
|
||||
let empty = blank
|
||||
&& !p.is_hub()
|
||||
&& p.page_type().is_none()
|
||||
&& p.tags.is_empty()
|
||||
&& p.description.trim().is_empty();
|
||||
let reason = if is_legacy_page(&p.title) {
|
||||
if key.starts_with("hls__") {
|
||||
"Logseq PDF highlights"
|
||||
@@ -221,10 +230,11 @@ impl SynapseGraph {
|
||||
}
|
||||
} else if p.properties.get("type").and_then(|v| v.as_str()) == Some("system") {
|
||||
"type:: system"
|
||||
} else if empty {
|
||||
"Empty"
|
||||
} else {
|
||||
continue;
|
||||
};
|
||||
let blocks = g.page_tree(p.id)?.len() as u32;
|
||||
let organisational = matches!(key.as_str(), "contents" | "card" | "favorites")
|
||||
|| key.starts_with("hls__");
|
||||
out.push(LegacyCandidate {
|
||||
@@ -232,7 +242,7 @@ impl SynapseGraph {
|
||||
title: p.title.clone(),
|
||||
reason: reason.into(),
|
||||
blocks,
|
||||
preselected: !p.is_hub() && (blocks == 0 || organisational),
|
||||
preselected: !p.is_hub() && (empty || blocks == 0 || organisational),
|
||||
});
|
||||
}
|
||||
out.sort_by_key(|c| title_key(&c.title));
|
||||
|
||||
@@ -47,6 +47,8 @@ crates may add their own tables to the same database (prefix them: `search_*`, `
|
||||
the first; `PageKind` has no `Tag` any more and "tag" parses as a note.
|
||||
- In the graph (`synapse-ffi`) every tag in use is a virtual node (`GraphNode.is_tag`, id
|
||||
`tag:<title_key>`, no page), with a `TAGGED` edge from each tagged page (type included).
|
||||
A tag named like a hub in the graph uses the hub's node instead; its members, already
|
||||
linked by `CONTAINS`, get no `TAGGED` edge.
|
||||
- Known limitations: replicas still on the old schema may overwrite tags with stale values (LWW per page), and `rename_tag` is a bulk page edit, so concurrent edits on another replica can undo part of it.
|
||||
- Exports use `synapse-tags::` and `synapse-type::` (see `history.md`).
|
||||
|
||||
@@ -90,8 +92,8 @@ Two orthogonal ways to organise pages.
|
||||
a hub; `convert_to_note` keeps such blocks. Clients older than schema v3 drop `kind`,
|
||||
`description` and `hubs` when they upsert a page, so every client must be on v3.
|
||||
- Logseq built-ins (`contents`, `TODO`, `hls__*`, ...) are recognised by `is_legacy_page`; the
|
||||
app offers to purge them (`legacy_candidates` / `purge_pages` in `synapse-ffi`). The importer
|
||||
only skips a narrower set (see `import.md`).
|
||||
app offers to purge them, together with empty pages (`legacy_candidates` / `purge_pages` in
|
||||
`synapse-ffi`). The importer only skips a narrower set (see `import.md`).
|
||||
|
||||
## Temporal model
|
||||
- `journal_neighbors(date)` gives the previous/next existing journal (episodic chain).
|
||||
|
||||
Reference in new issue
Block a user