mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
fixed bug with start node when reloading the tree
This commit is contained in:
parent
ae23f2ea84
commit
df7a39776d
@ -3,6 +3,7 @@
|
||||
const noteTree = (function() {
|
||||
const noteDetailEl = $('#note-detail');
|
||||
const treeEl = $("#tree");
|
||||
let startNoteId = null;
|
||||
let treeLoadTime = null;
|
||||
let clipboardNoteId = null;
|
||||
|
||||
@ -55,7 +56,7 @@ const noteTree = (function() {
|
||||
});
|
||||
}
|
||||
|
||||
function initFancyTree(notes, startNoteId) {
|
||||
function initFancyTree(notes) {
|
||||
const keybindings = {
|
||||
"insert": node => {
|
||||
const parentKey = treeUtils.getParentKey(node);
|
||||
@ -188,10 +189,19 @@ const noteTree = (function() {
|
||||
treeEl.contextmenu(contextMenu.contextMenuSettings);
|
||||
}
|
||||
|
||||
async function reload() {
|
||||
const treeResp = await loadTree();
|
||||
|
||||
// this will also reload the note content
|
||||
await treeEl.fancytree('getTree').reload(treeResp.notes);
|
||||
|
||||
encryption.decryptTreeItems();
|
||||
}
|
||||
|
||||
function loadTree() {
|
||||
return $.get(baseApiUrl + 'tree').then(resp => {
|
||||
const notes = resp.notes;
|
||||
let startNoteId = resp.start_note_id;
|
||||
startNoteId = resp.start_note_id;
|
||||
treeLoadTime = resp.tree_load_time;
|
||||
|
||||
// add browser ID header to all AJAX requests
|
||||
@ -212,11 +222,7 @@ const noteTree = (function() {
|
||||
});
|
||||
}
|
||||
|
||||
$(() => {
|
||||
loadTree().then(resp => {
|
||||
initFancyTree(resp.notes, resp.startNoteId);
|
||||
});
|
||||
});
|
||||
$(() => loadTree().then(resp => initFancyTree(resp.notes)));
|
||||
|
||||
function collapseTree() {
|
||||
treeEl.fancytree("getRootNode").visit(node => {
|
||||
@ -289,7 +295,7 @@ const noteTree = (function() {
|
||||
getTreeLoadTime,
|
||||
getClipboardNoteId,
|
||||
setClipboardNoteId,
|
||||
loadTree,
|
||||
reload,
|
||||
collapseTree,
|
||||
scrollToCurrentNote,
|
||||
toggleSearch,
|
||||
|
@ -28,14 +28,9 @@ const status = (function() {
|
||||
});
|
||||
|
||||
if (resp.changedTree) {
|
||||
const treeResp = await noteTree.loadTree();
|
||||
|
||||
console.log("Reloading tree because of background changes");
|
||||
|
||||
// this will also reload the note content
|
||||
await treeEl.fancytree('getTree').reload(treeResp.notes);
|
||||
|
||||
encryption.decryptTreeItems();
|
||||
noteTree.reload();
|
||||
}
|
||||
|
||||
$changesToPushCountEl.html(resp.changesToPushCount);
|
||||
|
Loading…
x
Reference in New Issue
Block a user