decoupled protected session holder from presentation stuff and similar things

This commit is contained in:
azivner
2018-03-25 21:16:57 -04:00
parent 47eb1e3e02
commit ac1b06967f
12 changed files with 130 additions and 99 deletions

View File

@@ -3,7 +3,7 @@ import dragAndDropSetup from './drag_and_drop.js';
import linkService from './link.js';
import messagingService from './messaging.js';
import noteDetailService from './note_detail.js';
import protectedSessionService from './protected_session.js';
import protectedSessionHolder from './protected_session_holder.js';
import treeChangesService from './tree_changes.js';
import treeUtils from './tree_utils.js';
import utils from './utils.js';
@@ -777,7 +777,7 @@ async function createNote(node, parentNoteId, target, isProtected) {
// if isProtected isn't available (user didn't enter password yet), then note is created as unencrypted
// but this is quite weird since user doesn't see WHERE the note is being created so it shouldn't occur often
if (!isProtected || !protectedSessionService.isProtectedSessionAvailable()) {
if (!isProtected || !protectedSessionHolder.isProtectedSessionAvailable()) {
isProtected = false;
}
@@ -857,6 +857,16 @@ async function getBranch(branchId) {
return await treeCache.getBranch(branchId);
}
messagingService.subscribeToMessages(syncData => {
if (syncData.some(sync => sync.entityName === 'branches')
|| syncData.some(sync => sync.entityName === 'notes')) {
console.log(utils.now(), "Reloading tree because of background changes");
reload();
}
});
$(document).bind('keydown', 'ctrl+o', e => {
const node = getCurrentNode();
const parentNoteId = node.data.parentNoteId;