diff --git a/src/becca/entities/note.js b/src/becca/entities/note.js
index e0b222772..083eac7f9 100644
--- a/src/becca/entities/note.js
+++ b/src/becca/entities/note.js
@@ -746,17 +746,23 @@ class Note extends AbstractEntity {
/** @return {Note[]} */
getSubtreeNotes(includeArchived = true) {
- if (this.isArchived) {
- return [];
+ const noteSet = new Set();
+
+ function addSubtreeNotesInner(note) {
+ if (!includeArchived && note.isArchived) {
+ return;
+ }
+
+ noteSet.add(note);
+
+ for (const childNote of note.children) {
+ addSubtreeNotesInner(childNote);
+ }
}
- const arr = [[this]];
+ addSubtreeNotesInner(this);
- for (const childNote of this.children) {
- arr.push(childNote.getSubtreeNotes(includeArchived));
- }
-
- return arr.flat();
+ return Array.from(noteSet);
}
/** @return {String[]} */
diff --git a/src/public/app/widgets/type_widgets/note_map.js b/src/public/app/widgets/type_widgets/note_map.js
index e44c4dbdb..ff723db11 100644
--- a/src/public/app/widgets/type_widgets/note_map.js
+++ b/src/public/app/widgets/type_widgets/note_map.js
@@ -87,33 +87,31 @@ export default class NoteMapTypeWidget extends TypeWidget {
.d3VelocityDecay(0.08)
.nodeCanvasObject((node, ctx) => this.paintNode(node, this.stringToColor(node.type), ctx))
.nodePointerAreaPaint((node, ctx) => this.paintNode(node, this.stringToColor(node.type), ctx))
- .nodeLabel(node => node.name)
- .maxZoom(7)
.nodePointerAreaPaint((node, color, ctx) => {
ctx.fillStyle = color;
ctx.beginPath();
ctx.arc(node.x, node.y, this.noteIdToSizeMap[node.id], 0, 2 * Math.PI, false);
ctx.fill();
})
- .linkLabel(l => `${l.source.name} - ${l.name} - ${l.target.name}`)
- .linkCanvasObject((link, ctx) => this.paintLink(link, ctx))
- .linkCanvasObjectMode(() => "after")
+ .nodeLabel(node => node.name)
+ .maxZoom(7)
.warmupTicks(10)
-// .linkDirectionalArrowLength(5)
+ .linkDirectionalArrowLength(5)
.linkDirectionalArrowRelPos(1)
.linkWidth(1)
.linkColor(() => this.css.mutedTextColor)
-// .d3VelocityDecay(0.2)
-// .dagMode("radialout")
.onNodeClick(node => this.nodeClicked(node));
+ if (this.mapType === 'link') {
+ this.graph
+ .linkLabel(l => `${l.source.name} - ${l.name} - ${l.target.name}`)
+ .linkCanvasObject((link, ctx) => this.paintLink(link, ctx))
+ .linkCanvasObjectMode(() => "after");
+ }
+
this.graph.d3Force('link').distance(40);
- //
this.graph.d3Force('center').strength(0.01);
- //
this.graph.d3Force('charge').strength(-30);
-
-
this.graph.d3Force('charge').distanceMax(1000);
let mapRootNoteId = this.note.getLabelValue("mapRootNoteId");
diff --git a/src/routes/api/link_map.js b/src/routes/api/link_map.js
index 91fe31a0a..8ef959e20 100644
--- a/src/routes/api/link_map.js
+++ b/src/routes/api/link_map.js
@@ -151,6 +151,19 @@ function getGlobalTreeMap(req) {
const notes = mapRootNote.getSubtreeNotes(false)
.filter(note => !note.hasLabel('excludeFromTreeMap'))
+ .filter(note => {
+ if (note.type !== 'image' || note.getChildNotes().length > 0) {
+ return true;
+ }
+
+ const imageLinkRelation = note.getTargetRelations().find(rel => rel.name === 'imageLink');
+
+ if (!imageLinkRelation) {
+ return true;
+ }
+
+ return !note.getParentNotes().find(parentNote => parentNote.noteId === imageLinkRelation.noteId);
+ })
.map(note => [
note.noteId,
note.isContentAvailable() ? note.title : '[protected]',
@@ -169,8 +182,7 @@ function getGlobalTreeMap(req) {
links.push({
id: branch.branchId,
sourceNoteId: branch.parentNoteId,
- targetNoteId: branch.noteId,
- name: 'branch'
+ targetNoteId: branch.noteId
});
}