From c2ad14ba186f5ba9e4179dc2b1186dceb3b39569 Mon Sep 17 00:00:00 2001 From: azivner Date: Tue, 14 Nov 2017 23:01:23 -0500 Subject: [PATCH] more cleanup --- public/javascripts/context_menu.js | 2 +- public/javascripts/dialogs/settings.js | 2 +- public/javascripts/note_editor.js | 10 ---------- public/javascripts/note_tree.js | 4 ++-- public/javascripts/protected_session.js | 10 +++++++++- public/javascripts/tree_utils.js | 4 ++-- 6 files changed, 15 insertions(+), 17 deletions(-) diff --git a/public/javascripts/context_menu.js b/public/javascripts/context_menu.js index a5ecee0d1..d573dabc9 100644 --- a/public/javascripts/context_menu.js +++ b/public/javascripts/context_menu.js @@ -57,7 +57,7 @@ const contextMenu = (function() { if (ui.cmd === "insertNoteHere") { const parentKey = treeUtils.getParentKey(node); - const isProtected = treeUtils.getParentEncryption(node); + const isProtected = treeUtils.getParentProtectedStatus(node); noteEditor.createNote(node, parentKey, 'after', isProtected); } diff --git a/public/javascripts/dialogs/settings.js b/public/javascripts/dialogs/settings.js index da1acd712..0fb2bc4b8 100644 --- a/public/javascripts/dialogs/settings.js +++ b/public/javascripts/dialogs/settings.js @@ -89,7 +89,7 @@ settings.addModule((function() { if (result.success) { alert("Password has been changed. Trilium will be reloaded after you press OK."); - // encryption password changed so current encryption session is invalid and needs to be cleared + // password changed so current protected session is invalid and needs to be cleared protected_session.resetProtectedSession(); } else { diff --git a/public/javascripts/note_editor.js b/public/javascripts/note_editor.js index 36d8b9edb..4f5902aba 100644 --- a/public/javascripts/note_editor.js +++ b/public/javascripts/note_editor.js @@ -7,8 +7,6 @@ const noteEditor = (function() { const protectButton = $("#protect-button"); const unprotectButton = $("#unprotect-button"); const noteDetailWrapperEl = $("#note-detail-wrapper"); - const encryptionPasswordDialogEl = $("#protected-session-password-dialog"); - const encryptionPasswordEl = $("#protected-session-password"); let currentNote = null; @@ -206,14 +204,6 @@ const noteEditor = (function() { noteDetailWrapperEl.show(); - // this may fal if the dialog has not been previously opened - try { - encryptionPasswordDialogEl.dialog('close'); - } - catch(e) {} - - encryptionPasswordEl.val(''); - noteTitleEl.val(currentNote.detail.note_title); noteChangeDisabled = true; diff --git a/public/javascripts/note_tree.js b/public/javascripts/note_tree.js index 2ea010d61..79866dfdf 100644 --- a/public/javascripts/note_tree.js +++ b/public/javascripts/note_tree.js @@ -58,9 +58,9 @@ const noteTree = (function() { const keybindings = { "insert": node => { const parentKey = treeUtils.getParentKey(node); - const encryption = treeUtils.getParentEncryption(node); + const isProtected = treeUtils.getParentProtectedStatus(node); - noteEditor.createNote(node, parentKey, 'after', encryption); + noteEditor.createNote(node, parentKey, 'after', isProtected); }, "ctrl+insert": node => { noteEditor.createNote(node, node.key, 'into', node.data.is_protected); diff --git a/public/javascripts/protected_session.js b/public/javascripts/protected_session.js index 5e32e94ae..67ddf0151 100644 --- a/public/javascripts/protected_session.js +++ b/public/javascripts/protected_session.js @@ -13,7 +13,7 @@ const protected_session = (function() { $.ajax({ url: baseApiUrl + 'settings/all', type: 'GET', - error: () => showError("Error getting encryption settings.") + error: () => showError("Error getting protected session settings.") }).then(settings => { protectedSessionTimeout = settings.protected_session_timeout; }); @@ -69,6 +69,14 @@ const protected_session = (function() { noteTree.reload(); if (protectedSessionDeferred !== null) { + // this may fal if the dialog has not been previously opened + try { + dialogEl.dialog('close'); + } + catch(e) {} + + passwordEl.val(''); + protectedSessionDeferred.resolve(); protectedSessionDeferred = null; diff --git a/public/javascripts/tree_utils.js b/public/javascripts/tree_utils.js index c63dc7a0b..db927deb4 100644 --- a/public/javascripts/tree_utils.js +++ b/public/javascripts/tree_utils.js @@ -7,7 +7,7 @@ const treeUtils = (function() { return (node.getParent() === null || node.getParent().key === "root_1") ? "root" : node.getParent().key; } - function getParentEncryption(node) { + function getParentProtectedStatus(node) { return node.getParent() === null ? 0 : node.getParent().data.is_protected; } @@ -64,7 +64,7 @@ const treeUtils = (function() { return { getParentKey, - getParentEncryption, + getParentProtectedStatus, getNodeByKey, activateNode, getNoteTitle,