link map lazy loading

This commit is contained in:
zadam
2021-06-01 22:03:38 +02:00
parent e48bbe5b19
commit 9a147365f5
4 changed files with 63 additions and 59 deletions

View File

@@ -40,9 +40,9 @@ function collectRelations(noteId, relations, depth) {
relations.add(relation);
if (relation.noteId !== noteId) {
collectRelations(relation.noteId, relations, depth--);
collectRelations(relation.noteId, relations, depth - 1);
} else if (relation.value !== noteId) {
collectRelations(relation.value, relations, depth--);
collectRelations(relation.value, relations, depth - 1);
}
}
}
@@ -71,6 +71,7 @@ function getLinkMap(req) {
return {
noteIdToLinkCountMap,
links: Array.from(relations).map(rel => ({
id: rel.noteId + "-" + rel.name + "-" + rel.value,
sourceNoteId: rel.noteId,
targetNoteId: rel.value,
name: rel.name