From cce8c1b674ab288c9e8fffbfb1a12d0c9d407954 Mon Sep 17 00:00:00 2001 From: azivner Date: Tue, 15 Jan 2019 20:30:54 +0100 Subject: [PATCH] create top level note and collapse tree now work relative to hoisted note, closes #343 --- src/public/javascripts/services/tree.js | 12 ++++++++---- src/services/sql_init.js | 1 - 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/public/javascripts/services/tree.js b/src/public/javascripts/services/tree.js index 480f6a182..15589a78e 100644 --- a/src/public/javascripts/services/tree.js +++ b/src/public/javascripts/services/tree.js @@ -498,9 +498,11 @@ async function loadTree() { return await treeBuilder.prepareTree(resp.notes, resp.branches, resp.relations); } -function collapseTree(node = null) { +async function collapseTree(node = null) { if (!node) { - node = $tree.fancytree("getRootNode"); + const hoistedNoteId = await hoistedNoteService.getHoistedNoteId(); + + node = getNodesByNoteId(hoistedNoteId)[0]; } node.setExpanded(false); @@ -541,9 +543,11 @@ async function setNoteTitle(noteId, title) { } async function createNewTopLevelNote() { - const rootNode = getNodesByNoteId('root')[0]; + const hoistedNoteId = await hoistedNoteService.getHoistedNoteId(); - await createNote(rootNode, "root", "into", false); + const rootNode = getNodesByNoteId(hoistedNoteId)[0]; + + await createNote(rootNode, hoistedNoteId, "into", false); } async function createNote(node, parentNoteId, target, isProtected, saveSelection = false) { diff --git a/src/services/sql_init.js b/src/services/sql_init.js index 3e4bc544d..4e7a1c17f 100644 --- a/src/services/sql_init.js +++ b/src/services/sql_init.js @@ -8,7 +8,6 @@ const sql = require('./sql'); const cls = require('./cls'); const optionService = require('./options'); const Option = require('../entities/option'); -const utils = require('../services/utils'); async function createConnection() { return await sqlite.open(dataDir.DOCUMENT_PATH, {Promise});