mirror of
https://github.com/Dasemu/Synapse.git
synced 2026-11-26 23:36:20 +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`.
|
/// journal); otherwise at the newest journal strictly before `before`.
|
||||||
Future<List<PageData>> journals({String? before, required int limit});
|
Future<List<PageData>> journals({String? before, required int limit});
|
||||||
|
|
||||||
/// Pages that are probably leftovers of Logseq: its built-ins and pages with
|
/// Pages worth cleaning up: leftovers of Logseq (its built-ins and pages with
|
||||||
/// `type:: system`. Only the organisational files (`contents`, `card`, `favorites`,
|
/// `type:: system`) and empty pages (no text in any block, not a hub, no type, tags or
|
||||||
/// `hls__*`) and empty pages are preselected, and never a hub: a built-in title such as
|
/// description). Of the Logseq ones only the organisational files (`contents`, `card`,
|
||||||
/// `todo` may hold real content.
|
/// `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();
|
Future<List<LegacyCandidate>> legacyCandidates();
|
||||||
|
|
||||||
/// Pages ordered by last update, most recent first.
|
/// Pages ordered by last update, most recent first.
|
||||||
|
|||||||
@@ -5290,10 +5290,11 @@ class SynapseGraphImpl extends RustOpaque implements SynapseGraph {
|
|||||||
limit: limit,
|
limit: limit,
|
||||||
);
|
);
|
||||||
|
|
||||||
/// Pages that are probably leftovers of Logseq: its built-ins and pages with
|
/// Pages worth cleaning up: leftovers of Logseq (its built-ins and pages with
|
||||||
/// `type:: system`. Only the organisational files (`contents`, `card`, `favorites`,
|
/// `type:: system`) and empty pages (no text in any block, not a hub, no type, tags or
|
||||||
/// `hls__*`) and empty pages are preselected, and never a hub: a built-in title such as
|
/// description). Of the Logseq ones only the organisational files (`contents`, `card`,
|
||||||
/// `todo` may hold real content.
|
/// `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
|
Future<List<LegacyCandidate>> legacyCandidates() => RustLib.instance.api
|
||||||
.crateApiGraphSynapseGraphLegacyCandidates(that: this);
|
.crateApiGraphSynapseGraphLegacyCandidates(that: this);
|
||||||
|
|
||||||
|
|||||||
@@ -374,21 +374,43 @@ class _CleanupDialogState extends State<CleanupDialog> {
|
|||||||
final colors = context.colors;
|
final colors = context.colors;
|
||||||
final items = widget.candidates;
|
final items = widget.candidates;
|
||||||
return AlertDialog(
|
return AlertDialog(
|
||||||
title: const Text('Remove legacy Logseq pages'),
|
title: const Text('Clean up pages'),
|
||||||
content: SizedBox(
|
content: SizedBox(
|
||||||
width: 460,
|
width: 460,
|
||||||
child: items.isEmpty
|
child: items.isEmpty
|
||||||
? Text(
|
? Text(
|
||||||
'No legacy pages found.',
|
'Nothing to clean up.',
|
||||||
style: TextStyle(color: colors.muted),
|
style: TextStyle(color: colors.muted),
|
||||||
)
|
)
|
||||||
: Column(
|
: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Row(
|
||||||
'This deletes the selected pages and their blocks.',
|
children: [
|
||||||
style: TextStyle(fontSize: 13, color: colors.muted),
|
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),
|
const SizedBox(height: 8),
|
||||||
Flexible(
|
Flexible(
|
||||||
|
|||||||
@@ -515,7 +515,7 @@ void main() {
|
|||||||
await pump(tester, b, home: const Scaffold(body: AllPagesView()));
|
await pump(tester, b, home: const Scaffold(body: AllPagesView()));
|
||||||
await tester.tap(find.text('Clean up'));
|
await tester.tap(find.text('Clean up'));
|
||||||
await settle(tester);
|
await settle(tester);
|
||||||
expect(find.text('Remove legacy Logseq pages'), findsOneWidget);
|
expect(find.text('Clean up pages'), findsOneWidget);
|
||||||
expect(find.text('Delete (2)'), findsOneWidget);
|
expect(find.text('Delete (2)'), findsOneWidget);
|
||||||
// Uncheck "card".
|
// Uncheck "card".
|
||||||
await tester.tap(
|
await tester.tap(
|
||||||
@@ -538,7 +538,7 @@ void main() {
|
|||||||
await pump(tester, demo(), home: const Scaffold(body: AllPagesView()));
|
await pump(tester, demo(), home: const Scaffold(body: AllPagesView()));
|
||||||
await tester.tap(find.text('Clean up'));
|
await tester.tap(find.text('Clean up'));
|
||||||
await settle(tester);
|
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
|
/// Pages worth cleaning up: leftovers of Logseq (its built-ins and pages with
|
||||||
/// `type:: system`. Only the organisational files (`contents`, `card`, `favorites`,
|
/// `type:: system`) and empty pages (no text in any block, not a hub, no type, tags or
|
||||||
/// `hls__*`) and empty pages are preselected, and never a hub: a built-in title such as
|
/// description). Of the Logseq ones only the organisational files (`contents`, `card`,
|
||||||
/// `todo` may hold real content.
|
/// `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>> {
|
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)? {
|
for p in g.list_pages(false, u32::MAX, 0)? {
|
||||||
let key = title_key(&p.title);
|
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) {
|
let reason = if is_legacy_page(&p.title) {
|
||||||
if key.starts_with("hls__") {
|
if key.starts_with("hls__") {
|
||||||
"Logseq PDF highlights"
|
"Logseq PDF highlights"
|
||||||
@@ -221,10 +230,11 @@ impl SynapseGraph {
|
|||||||
}
|
}
|
||||||
} else if p.properties.get("type").and_then(|v| v.as_str()) == Some("system") {
|
} else if p.properties.get("type").and_then(|v| v.as_str()) == Some("system") {
|
||||||
"type:: system"
|
"type:: system"
|
||||||
|
} else if empty {
|
||||||
|
"Empty"
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
let blocks = g.page_tree(p.id)?.len() as u32;
|
|
||||||
let organisational = matches!(key.as_str(), "contents" | "card" | "favorites")
|
let organisational = matches!(key.as_str(), "contents" | "card" | "favorites")
|
||||||
|| key.starts_with("hls__");
|
|| key.starts_with("hls__");
|
||||||
out.push(LegacyCandidate {
|
out.push(LegacyCandidate {
|
||||||
@@ -232,7 +242,7 @@ impl SynapseGraph {
|
|||||||
title: p.title.clone(),
|
title: p.title.clone(),
|
||||||
reason: reason.into(),
|
reason: reason.into(),
|
||||||
blocks,
|
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));
|
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.
|
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
|
- 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).
|
`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.
|
- 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`).
|
- 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`,
|
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.
|
`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
|
- 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
|
app offers to purge them, together with empty pages (`legacy_candidates` / `purge_pages` in
|
||||||
only skips a narrower set (see `import.md`).
|
`synapse-ffi`). The importer only skips a narrower set (see `import.md`).
|
||||||
|
|
||||||
## Temporal model
|
## Temporal model
|
||||||
- `journal_neighbors(date)` gives the previous/next existing journal (episodic chain).
|
- `journal_neighbors(date)` gives the previous/next existing journal (episodic chain).
|
||||||
|
|||||||
Reference in new issue
Block a user