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 noteTree = (function() {
|
||||||
const noteDetailEl = $('#note-detail');
|
const noteDetailEl = $('#note-detail');
|
||||||
const treeEl = $("#tree");
|
const treeEl = $("#tree");
|
||||||
|
let startNoteId = null;
|
||||||
let treeLoadTime = null;
|
let treeLoadTime = null;
|
||||||
let clipboardNoteId = null;
|
let clipboardNoteId = null;
|
||||||
|
|
||||||
@ -55,7 +56,7 @@ const noteTree = (function() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function initFancyTree(notes, startNoteId) {
|
function initFancyTree(notes) {
|
||||||
const keybindings = {
|
const keybindings = {
|
||||||
"insert": node => {
|
"insert": node => {
|
||||||
const parentKey = treeUtils.getParentKey(node);
|
const parentKey = treeUtils.getParentKey(node);
|
||||||
@ -188,10 +189,19 @@ const noteTree = (function() {
|
|||||||
treeEl.contextmenu(contextMenu.contextMenuSettings);
|
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() {
|
function loadTree() {
|
||||||
return $.get(baseApiUrl + 'tree').then(resp => {
|
return $.get(baseApiUrl + 'tree').then(resp => {
|
||||||
const notes = resp.notes;
|
const notes = resp.notes;
|
||||||
let startNoteId = resp.start_note_id;
|
startNoteId = resp.start_note_id;
|
||||||
treeLoadTime = resp.tree_load_time;
|
treeLoadTime = resp.tree_load_time;
|
||||||
|
|
||||||
// add browser ID header to all AJAX requests
|
// add browser ID header to all AJAX requests
|
||||||
@ -212,11 +222,7 @@ const noteTree = (function() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$(() => {
|
$(() => loadTree().then(resp => initFancyTree(resp.notes)));
|
||||||
loadTree().then(resp => {
|
|
||||||
initFancyTree(resp.notes, resp.startNoteId);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
function collapseTree() {
|
function collapseTree() {
|
||||||
treeEl.fancytree("getRootNode").visit(node => {
|
treeEl.fancytree("getRootNode").visit(node => {
|
||||||
@ -289,7 +295,7 @@ const noteTree = (function() {
|
|||||||
getTreeLoadTime,
|
getTreeLoadTime,
|
||||||
getClipboardNoteId,
|
getClipboardNoteId,
|
||||||
setClipboardNoteId,
|
setClipboardNoteId,
|
||||||
loadTree,
|
reload,
|
||||||
collapseTree,
|
collapseTree,
|
||||||
scrollToCurrentNote,
|
scrollToCurrentNote,
|
||||||
toggleSearch,
|
toggleSearch,
|
||||||
|
@ -28,14 +28,9 @@ const status = (function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (resp.changedTree) {
|
if (resp.changedTree) {
|
||||||
const treeResp = await noteTree.loadTree();
|
|
||||||
|
|
||||||
console.log("Reloading tree because of background changes");
|
console.log("Reloading tree because of background changes");
|
||||||
|
|
||||||
// this will also reload the note content
|
noteTree.reload();
|
||||||
await treeEl.fancytree('getTree').reload(treeResp.notes);
|
|
||||||
|
|
||||||
encryption.decryptTreeItems();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$changesToPushCountEl.html(resp.changesToPushCount);
|
$changesToPushCountEl.html(resp.changesToPushCount);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user