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") {
const parentKey = treeUtils.getParentKey(node);
const isProtected = treeUtils.getParentEncryption(node);
const isProtected = treeUtils.getParentProtectedStatus(node);
noteEditor.createNote(node, parentKey, 'after', isProtected);
}

View file

@ -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 {

View file

@ -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;

View file

@ -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);

View file

@ -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;

View file

@ -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,