From 89c04e6b6bb5aed8eaaf39a15301487d9b7708c8 Mon Sep 17 00:00:00 2001 From: zadam Date: Sat, 4 Dec 2021 13:33:31 +0100 Subject: [PATCH 1/2] fix "note paths" ribbon widget for root note --- .idea/runConfigurations.xml | 10 ---------- package.json | 2 +- src/public/app/widgets/ribbon_widgets/note_paths.js | 13 ++++++++----- 3 files changed, 9 insertions(+), 16 deletions(-) delete mode 100644 .idea/runConfigurations.xml diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml deleted file mode 100644 index 797acea53..000000000 --- a/.idea/runConfigurations.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/package.json b/package.json index 60d622c25..a8bb5d57f 100644 --- a/package.json +++ b/package.json @@ -81,7 +81,7 @@ }, "devDependencies": { "cross-env": "7.0.3", - "electron": "13.6.2", + "electron": "13.6.3", "electron-builder": "22.13.1", "electron-packager": "15.4.0", "electron-rebuild": "3.2.3", diff --git a/src/public/app/widgets/ribbon_widgets/note_paths.js b/src/public/app/widgets/ribbon_widgets/note_paths.js index fd7a1c906..225cbef69 100644 --- a/src/public/app/widgets/ribbon_widgets/note_paths.js +++ b/src/public/app/widgets/ribbon_widgets/note_paths.js @@ -69,7 +69,10 @@ export default class NotePathsWidget extends NoteContextAwareWidget { this.$notePathList.empty(); if (this.noteId === 'root') { - await this.getRenderedPath('root'); + this.$notePathList.empty().append( + await this.getRenderedPath('root') + ); + return; } @@ -94,7 +97,7 @@ export default class NotePathsWidget extends NoteContextAwareWidget { this.$notePathList.empty().append(...renderedPaths); } - async getRenderedPath(notePath, notePathRecord) { + async getRenderedPath(notePath, notePathRecord = null) { const title = await treeService.getNotePathTitle(notePath); const $noteLink = await linkService.createNoteLink(notePath, {title}); @@ -109,20 +112,20 @@ export default class NotePathsWidget extends NoteContextAwareWidget { $noteLink.addClass("path-current"); } - if (notePathRecord.isInHoistedSubTree) { + if (!notePathRecord || notePathRecord.isInHoistedSubTree) { $noteLink.addClass("path-in-hoisted-subtree"); } else { icons.push(``); } - if (notePathRecord.isArchived) { + if (notePathRecord?.isArchived) { $noteLink.addClass("path-archived"); icons.push(``); } - if (notePathRecord.isSearch) { + if (notePathRecord?.isSearch) { $noteLink.addClass("path-search"); icons.push(``); From 26bcfe516098ec80e637a04fd407d1a917a78e22 Mon Sep 17 00:00:00 2001 From: zadam Date: Sat, 4 Dec 2021 13:45:15 +0100 Subject: [PATCH 2/2] fix hidden notes appearing in note map, closes #2403 --- src/routes/api/note_map.js | 10 ++++++++++ src/services/special_notes.js | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/src/routes/api/note_map.js b/src/routes/api/note_map.js index a14922b1d..b0dc6d57e 100644 --- a/src/routes/api/note_map.js +++ b/src/routes/api/note_map.js @@ -42,6 +42,11 @@ function getNeighbors(note, depth) { } const targetNote = relation.getTargetNote(); + + if (targetNote.hasLabel('excludeFromNoteMap')) { + continue; + } + retNoteIds.push(targetNote.noteId); for (const noteId of getNeighbors(targetNote, depth - 1)) { @@ -56,6 +61,11 @@ function getNeighbors(note, depth) { } const sourceNote = relation.getNote(); + + if (sourceNote.hasLabel('excludeFromNoteMap')) { + continue; + } + retNoteIds.push(sourceNote.noteId); for (const noteId of getNeighbors(sourceNote, depth - 1)) { diff --git a/src/services/special_notes.js b/src/services/special_notes.js index 46627e0da..9c27f7f14 100644 --- a/src/services/special_notes.js +++ b/src/services/special_notes.js @@ -44,6 +44,7 @@ function getHiddenRoot() { // isInheritable: false means that this notePath is automatically not preffered but at the same time // the flag is not inherited to the children hidden.addLabel('archived', "", false); + hidden.addLabel('excludeFromNoteMap', "", true); } return hidden; @@ -206,6 +207,12 @@ function createMissingSpecialNotes() { getSinglesNoteRoot(); getSinglesNoteRoot(); getGlobalNoteMap(); + + const hidden = getHiddenRoot(); + + if (!hidden.hasOwnedLabel('excludeFromNoteMap')) { + hidden.addLabel('excludeFromNoteMap', "", true); + } } module.exports = {