tweaks to note map

This commit is contained in:
zadam
2021-09-21 22:45:06 +02:00
parent b0d767df69
commit 208492bee1
3 changed files with 38 additions and 22 deletions

View File

@@ -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[]} */