Skip to content

Build your personal knowledge base with Trilium Notes

fixing encrypt / decrypt subtree

azivnerb96e43434563
diff --git a/public/javascripts/context_menu.js b/public/javascripts/context_menu.js
index 4f3fdd950a..66bb37d86e 100644
--- a/public/javascripts/context_menu.js
+++ b/public/javascripts/context_menu.js
@@ -45,9 +45,6 @@ const contextMenu = (function() {
treeEl.contextmenu("enableEntry", "pasteAfter", noteTree.getClipboardNoteTreeId() !== null);
treeEl.contextmenu("enableEntry", "pasteInto", noteTree.getClipboardNoteTreeId() !== null);
- treeEl.contextmenu("enableEntry", "protectSubTree", protected_session.isProtectedSessionAvailable());
- treeEl.contextmenu("enableEntry", "unprotectSubTree", protected_session.isProtectedSessionAvailable());
-
// Activate node on right-click
node.setActive();
// Disable tree keyboard handling
@@ -65,13 +62,13 @@ const contextMenu = (function() {
noteEditor.createNote(node, parentNoteTreeId, 'after', isProtected);
}
else if (ui.cmd === "insertChildNote") {
- noteEditor.createNote(node, node.key, 'into');
+ noteEditor.createNote(node, node.data.note_id, 'into');
}
else if (ui.cmd === "protectSubTree") {
- protected_session.protectSubTree(node.key, true);
+ protected_session.protectSubTree(node.data.note_id, true);
}
else if (ui.cmd === "unprotectSubTree") {
- protected_session.protectSubTree(node.key, false);
+ protected_session.protectSubTree(node.data.note_id, false);
}
else if (ui.cmd === "cut") {
cut(node);
diff --git a/public/javascripts/protected_session.js b/public/javascripts/protected_session.js
index 0da7f07cb8..58aef9d397 100644
--- a/public/javascripts/protected_session.js
+++ b/public/javascripts/protected_session.js
@@ -152,6 +152,8 @@ const protected_session = (function() {
}
async function protectSubTree(noteId, protect) {
+ await ensureProtectedSession(true, true);
+
await $.ajax({
url: baseApiUrl + 'tree/' + noteId + "/protectSubTree/" + (protect ? 1 : 0),
type: 'PUT',