more cleanup

This commit is contained in:
azivner 2017-11-14 23:01:23 -05:00
parent 98a2322b37
commit c2ad14ba18
6 changed files with 15 additions and 17 deletions

View File

@ -57,7 +57,7 @@ const contextMenu = (function() {
if (ui.cmd === "insertNoteHere") { if (ui.cmd === "insertNoteHere") {
const parentKey = treeUtils.getParentKey(node); const parentKey = treeUtils.getParentKey(node);
const isProtected = treeUtils.getParentEncryption(node); const isProtected = treeUtils.getParentProtectedStatus(node);
noteEditor.createNote(node, parentKey, 'after', isProtected); noteEditor.createNote(node, parentKey, 'after', isProtected);
} }

View File

@ -89,7 +89,7 @@ settings.addModule((function() {
if (result.success) { if (result.success) {
alert("Password has been changed. Trilium will be reloaded after you press OK."); 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(); protected_session.resetProtectedSession();
} }
else { else {

View File

@ -7,8 +7,6 @@ const noteEditor = (function() {
const protectButton = $("#protect-button"); const protectButton = $("#protect-button");
const unprotectButton = $("#unprotect-button"); const unprotectButton = $("#unprotect-button");
const noteDetailWrapperEl = $("#note-detail-wrapper"); const noteDetailWrapperEl = $("#note-detail-wrapper");
const encryptionPasswordDialogEl = $("#protected-session-password-dialog");
const encryptionPasswordEl = $("#protected-session-password");
let currentNote = null; let currentNote = null;
@ -206,14 +204,6 @@ const noteEditor = (function() {
noteDetailWrapperEl.show(); 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); noteTitleEl.val(currentNote.detail.note_title);
noteChangeDisabled = true; noteChangeDisabled = true;

View File

@ -58,9 +58,9 @@ const noteTree = (function() {
const keybindings = { const keybindings = {
"insert": node => { "insert": node => {
const parentKey = treeUtils.getParentKey(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 => { "ctrl+insert": node => {
noteEditor.createNote(node, node.key, 'into', node.data.is_protected); noteEditor.createNote(node, node.key, 'into', node.data.is_protected);

View File

@ -13,7 +13,7 @@ const protected_session = (function() {
$.ajax({ $.ajax({
url: baseApiUrl + 'settings/all', url: baseApiUrl + 'settings/all',
type: 'GET', type: 'GET',
error: () => showError("Error getting encryption settings.") error: () => showError("Error getting protected session settings.")
}).then(settings => { }).then(settings => {
protectedSessionTimeout = settings.protected_session_timeout; protectedSessionTimeout = settings.protected_session_timeout;
}); });
@ -69,6 +69,14 @@ const protected_session = (function() {
noteTree.reload(); noteTree.reload();
if (protectedSessionDeferred !== null) { 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.resolve();
protectedSessionDeferred = null; protectedSessionDeferred = null;

View File

@ -7,7 +7,7 @@ const treeUtils = (function() {
return (node.getParent() === null || node.getParent().key === "root_1") ? "root" : node.getParent().key; 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; return node.getParent() === null ? 0 : node.getParent().data.is_protected;
} }
@ -64,7 +64,7 @@ const treeUtils = (function() {
return { return {
getParentKey, getParentKey,
getParentEncryption, getParentProtectedStatus,
getNodeByKey, getNodeByKey,
activateNode, activateNode,
getNoteTitle, getNoteTitle,