protected notes are not in autocomplete when not in protected session, fixes #46

This commit is contained in:
azivner 2018-04-08 12:27:10 -04:00
parent 5b0e1a644d
commit b277a250e5
2 changed files with 9 additions and 8 deletions

View File

@ -12,7 +12,8 @@ class Note extends Entity {
constructor(row) { constructor(row) {
super(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); protected_session.decryptNote(this);
} }

View File

@ -1,5 +1,6 @@
import treeCache from "./tree_cache.js"; import treeCache from "./tree_cache.js";
import treeUtils from "./tree_utils.js"; import treeUtils from "./tree_utils.js";
import protectedSessionHolder from './protected_session_holder.js';
async function getAutocompleteItems(parentNoteId, notePath, titlePath) { async function getAutocompleteItems(parentNoteId, notePath, titlePath) {
if (!parentNoteId) { if (!parentNoteId) {
@ -21,9 +22,6 @@ async function getAutocompleteItems(parentNoteId, notePath, titlePath) {
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 = []; const autocompleteItems = [];
for (const childNote of childNotes) { for (const childNote of childNotes) {
@ -34,10 +32,12 @@ async function getAutocompleteItems(parentNoteId, notePath, titlePath) {
const childNotePath = (notePath ? (notePath + '/') : '') + childNote.noteId; const childNotePath = (notePath ? (notePath + '/') : '') + childNote.noteId;
const childTitlePath = (titlePath ? (titlePath + ' / ') : '') + await treeUtils.getNoteTitle(childNote.noteId, parentNoteId); const childTitlePath = (titlePath ? (titlePath + ' / ') : '') + await treeUtils.getNoteTitle(childNote.noteId, parentNoteId);
autocompleteItems.push({ if (!childNote.isProtected || protectedSessionHolder.isProtectedSessionAvailable()) {
value: childTitlePath + ' (' + childNotePath + ')', autocompleteItems.push({
label: childTitlePath value: childTitlePath + ' (' + childNotePath + ')',
}); label: childTitlePath
});
}
const childItems = await getAutocompleteItems(childNote.noteId, childNotePath, childTitlePath); const childItems = await getAutocompleteItems(childNote.noteId, childNotePath, childTitlePath);