mirror of
https://github.com/Dasemu/Synapse.git
synced 2026-11-26 15:26:17 +00:00
feat(core): a page's direct hub is an implicit tag
Members of a hub are indexed under the hub's title in page_tags, tag_catalog and the graph tag nodes, merged with a same-name type or tag. Hub rename, delete and membership changes re-index the derived index (no ops). Schema v7 rebuilds it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3585ce67af
commit
6f483ce763
10 files changed
+273
-77
No files matched your search
@@ -173,12 +173,12 @@ class GraphModel {
|
||||
];
|
||||
}
|
||||
|
||||
/// Tag nodes (and pages targeted by inline `#tag` references) actually used as tags,
|
||||
/// most used first.
|
||||
/// Virtual tag nodes in use (targets of `TAGGED` edges), most used first. Pages targeted
|
||||
/// by inline `#x` references are ordinary notes and are not listed.
|
||||
late final List<int> tags = () {
|
||||
final count = <int, int>{};
|
||||
for (var e = 0; e < edgeCount; e++) {
|
||||
if (kind(e) == EdgeKind.tag || kind(e) == EdgeKind.tagged) {
|
||||
if (kind(e) == EdgeKind.tagged && isTag(target(e))) {
|
||||
count[target(e)] = (count[target(e)] ?? 0) + 1;
|
||||
}
|
||||
}
|
||||
@@ -307,13 +307,28 @@ class GraphFilter {
|
||||
'-${d.day.toString().padLeft(2, '0')}';
|
||||
}
|
||||
|
||||
bool inRange(int i) =>
|
||||
(from == null || day(i).compareTo(from!) >= 0) &&
|
||||
(to == null || day(i).compareTo(to!) <= 0);
|
||||
// A tag node has no creation date: it stays when one of its tagged pages is in range.
|
||||
bool tagInRange(int i) {
|
||||
if (from == null && to == null) return true;
|
||||
for (final e in g.adjacency[i]) {
|
||||
if (g.kind(e) != EdgeKind.tagged || g.target(e) != i) continue;
|
||||
final p = g.source(e);
|
||||
if (!g.isTag(p) && (journals || !g.isJournal(p)) && inRange(p)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
final base = <int>[
|
||||
for (var i = 0; i < g.nodeCount; i++)
|
||||
if ((journals || !g.isJournal(i)) &&
|
||||
(tagged == null || tagged.contains(i)) &&
|
||||
(q.isEmpty || g.node(i).title.toLowerCase().contains(q)) &&
|
||||
(from == null || day(i).compareTo(from!) >= 0) &&
|
||||
(to == null || day(i).compareTo(to!) <= 0))
|
||||
(g.isTag(i) ? tagInRange(i) : inRange(i)))
|
||||
i,
|
||||
];
|
||||
if (orphans && minDegree == 0) return base;
|
||||
|
||||
@@ -199,7 +199,7 @@ class NetworkCanvasState extends State<NetworkCanvas>
|
||||
? -1
|
||||
: (() {
|
||||
final i = g.tags.indexOf(n.primaryTag!);
|
||||
return i < 10 ? i : -1;
|
||||
return i >= 0 && i < 10 ? i : -1;
|
||||
})(),
|
||||
ColorBy.hub =>
|
||||
n.homeHub == null
|
||||
|
||||
Reference in new issue
Block a user