mirror of
https://github.com/zadam/trilium.git
synced 2024-09-22 16:46:09 +08:00
link map will try to display max possible number of links
This commit is contained in:
parent
2cfe9b3c03
commit
521a9b0b2c
|
@ -23,27 +23,29 @@ async function getLinkMap(req) {
|
||||||
|
|
||||||
let depth = 0;
|
let depth = 0;
|
||||||
|
|
||||||
while (true) {
|
while (noteIds.size < maxNotes) {
|
||||||
relations = await getRelations(noteIds);
|
relations = await getRelations(noteIds);
|
||||||
|
|
||||||
if (depth === maxDepth) {
|
if (depth === maxDepth) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const newNoteIds = new Set(relations.map(rel => rel.noteId)
|
let newNoteIds = relations.map(rel => rel.noteId)
|
||||||
.concat(relations.map(rel => rel.targetNoteId)));
|
.concat(relations.map(rel => rel.targetNoteId))
|
||||||
|
.filter(noteId => !noteIds.has(noteId));
|
||||||
|
|
||||||
if (newNoteIds.size === noteIds.size) {
|
if (newNoteIds.length === 0) {
|
||||||
// no new note discovered, no need to search any further
|
// no new note discovered, no need to search any further
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newNoteIds.size > maxNotes) {
|
for (const newNoteId of newNoteIds) {
|
||||||
// too many notes to display
|
noteIds.add(newNoteId);
|
||||||
|
|
||||||
|
if (noteIds.size >= maxNotes) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
noteIds = newNoteIds;
|
|
||||||
|
|
||||||
depth++;
|
depth++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,7 +102,7 @@ async function createNewNote(parentNoteId, noteData) {
|
||||||
mime: noteData.mime || 'text/html'
|
mime: noteData.mime || 'text/html'
|
||||||
}).save();
|
}).save();
|
||||||
|
|
||||||
if (note.isStringNote()) {
|
if (note.isStringNote() || this.type === 'render') { // render to just make sure it's not null
|
||||||
noteData.content = noteData.content || "";
|
noteData.content = noteData.content || "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue