From cdf94181d26bbbeea41d63a8ce99618b18d86c84 Mon Sep 17 00:00:00 2001 From: azivner Date: Sun, 25 Mar 2018 22:56:23 -0400 Subject: [PATCH] got rid of instanceName in tree service --- src/public/javascripts/services/script_api.js | 2 +- src/public/javascripts/services/tree.js | 11 ++--------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/public/javascripts/services/script_api.js b/src/public/javascripts/services/script_api.js index a6992f1a7..bf6ed0b1f 100644 --- a/src/public/javascripts/services/script_api.js +++ b/src/public/javascripts/services/script_api.js @@ -51,7 +51,7 @@ function ScriptApi(startNote, currentNote) { currentNote: currentNote, addButtonToToolbar, activateNote, - getInstanceName: treeService.getInstanceName, + getInstanceName: () => window.glob.instanceName, runOnServer } } diff --git a/src/public/javascripts/services/tree.js b/src/public/javascripts/services/tree.js index 93a772031..5892f2456 100644 --- a/src/public/javascripts/services/tree.js +++ b/src/public/javascripts/services/tree.js @@ -20,8 +20,6 @@ const $createTopLevelNoteButton = $("#create-top-level-note-button"); const $collapseTreeButton = $("#collapse-tree-button"); const $scrollToCurrentNoteButton = $("#scroll-to-current-note-button"); -let instanceName = null; // should have better place - let startNotePath = null; async function getNoteTitle(noteId, parentNoteId = null) { @@ -656,7 +654,7 @@ function getNotePathFromAddress() { async function loadTree() { const resp = await server.get('tree'); startNotePath = resp.start_note_path; - instanceName = resp.instanceName; + window.glob.instanceName = resp.instanceName; if (document.location.hash) { startNotePath = getNotePathFromAddress(); @@ -838,10 +836,6 @@ async function sortAlphabetically(noteId) { await reload(); } -function getInstanceName() { - return instanceName; -} - messagingService.subscribeToMessages(syncData => { if (syncData.some(sync => sync.entityName === 'branches') || syncData.some(sync => sync.entityName === 'notes')) { @@ -909,6 +903,5 @@ export default { removeParentChildRelation, setParentChildRelation, getSelectedNodes, - sortAlphabetically, - getInstanceName + sortAlphabetically }; \ No newline at end of file