create top level note and collapse tree now work relative to hoisted note, closes #343

This commit is contained in:
azivner 2019-01-15 20:30:54 +01:00
parent aa58788769
commit cce8c1b674
2 changed files with 8 additions and 5 deletions

View file

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

View file

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