Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
protected notes are not in autocomplete when not in protected session, fixes #46
azivnerb277a250e5d9
diff --git a/src/entities/note.js b/src/entities/note.jsindex 2b5e9e7b7a..9f599c5f19 100644--- a/src/entities/note.js+++ b/src/entities/note.js@@ -12,7 +12,8 @@ class Note extends Entity {constructor(row) {super(row);- if (this.isProtected) {+ // check if there's noteId, otherwise this is a new entity which wasn't encrypted yet+ if (this.isProtected && this.noteId) {protected_session.decryptNote(this);}diff --git a/src/public/javascripts/services/autocomplete.js b/src/public/javascripts/services/autocomplete.jsindex 7054c14d75..7243a53f97 100644--- a/src/public/javascripts/services/autocomplete.js+++ b/src/public/javascripts/services/autocomplete.js@@ -1,5 +1,6 @@import treeCache from "./tree_cache.js";import treeUtils from "./tree_utils.js";+import protectedSessionHolder from './protected_session_holder.js';async function getAutocompleteItems(parentNoteId, notePath, titlePath) {if (!parentNoteId) {@@ -21,9 +22,6 @@ async function getAutocompleteItems(parentNoteId, notePath, titlePath) {titlePath = '';}- // https://github.com/zadam/trilium/issues/46- // unfortunately not easy to implement because we don't have an easy access to note's isProtected property-const autocompleteItems = [];for (const childNote of childNotes) {@@ -34,10 +32,12 @@ async function getAutocompleteItems(parentNoteId, notePath, titlePath) {const childNotePath = (notePath ? (notePath + '/') : '') + childNote.noteId;const childTitlePath = (titlePath ? (titlePath + ' / ') : '') + await treeUtils.getNoteTitle(childNote.noteId, parentNoteId);- autocompleteItems.push({- value: childTitlePath + ' (' + childNotePath + ')',- label: childTitlePath- });+ if (!childNote.isProtected || protectedSessionHolder.isProtectedSessionAvailable()) {+ autocompleteItems.push({+ value: childTitlePath + ' (' + childNotePath + ')',+ label: childTitlePath+ });+ }const childItems = await getAutocompleteItems(childNote.noteId, childNotePath, childTitlePath);