Skip to content

Build your personal knowledge base with Trilium Notes

note map can display notes if hoisted in hidden subtree

zadamc34bccf7e876
diff --git a/src/becca/entities/note.js b/src/becca/entities/note.js
index 787c6f4f86..58ecf51fba 100644
--- a/src/becca/entities/note.js
+++ b/src/becca/entities/note.js
@@ -887,7 +887,7 @@ class Note extends AbstractEntity {
/**
* @returns {{notes: Note[], relationships: Array.<{parentNoteId: string, childNoteId: string}>}}
*/
- getSubtree({includeArchived = true, resolveSearch = false} = {}) {
+ getSubtree({includeArchived = true, includeHidden = false, resolveSearch = false} = {}) {
const noteSet = new Set();
const relationships = []; // list of tuples parentNoteId -> childNoteId
@@ -903,8 +903,7 @@ class Note extends AbstractEntity {
}
function addSubtreeNotesInner(note, parentNote = null) {
- // share can be removed after 0.57 since it will be put under hidden
- if (note.noteId === '_hidden' || note.noteId === '_share') {
+ if (note.noteId === '_hidden' && !includeHidden) {
return;
}
@@ -1042,6 +1041,10 @@ class Note extends AbstractEntity {
return false;
}
+ isInHiddenSubtree() {
+ return this.noteId === '_hidden' || this.hasAncestor('_hidden');
+ }
+
getTargetRelations() {
return this.targetRelations;
}
diff --git a/src/public/app/entities/note_short.js b/src/public/app/entities/note_short.js
index 65ae54d7f8..e496c65438 100644
--- a/src/public/app/entities/note_short.js
+++ b/src/public/app/entities/note_short.js
@@ -710,6 +710,10 @@ class NoteShort {
return false;
}
+ isInHiddenSubtree() {
+ return this.noteId === '_hidden' || this.hasAncestor('_hidden');
+ }
+
/**
* @deprecated NOOP
*/
diff --git a/src/routes/api/note_map.js b/src/routes/api/note_map.js
index 36072e04a5..91c24a27b3 100644
--- a/src/routes/api/note_map.js
+++ b/src/routes/api/note_map.js
@@ -93,7 +93,11 @@ function getLinkMap(req) {
// for search notes we want to consider the direct search results only without the descendants
unfilteredNotes = mapRootNote.getSearchResultNotes();
} else {
- unfilteredNotes = mapRootNote.getSubtree({includeArchived: false, resolveSearch: true}).notes;
+ unfilteredNotes = mapRootNote.getSubtree({
+ includeArchived: false,
+ resolveSearch: true,
+ includeHidden: mapRootNote.isInHiddenSubtree()
+ }).notes;
}
const noteIds = new Set(
@@ -156,7 +160,11 @@ function getTreeMap(req) {
// if the map root itself has ignore (journal typically) then there wouldn't be anything to display so
// we'll just ignore it
const ignoreExcludeFromNoteMap = mapRootNote.hasLabel('excludeFromNoteMap');
- const subtree = mapRootNote.getSubtree({includeArchived: false, resolveSearch: true});
+ const subtree = mapRootNote.getSubtree({
+ includeArchived: false,
+ resolveSearch: true,
+ includeHidden: mapRootNote.isInHiddenSubtree()
+ });
const notes = subtree.notes
.filter(note => ignoreExcludeFromNoteMap || !note.hasLabel('excludeFromNoteMap'))