mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 09:58:32 +02:00
reloading tree now doesn't force note reload
This commit is contained in:
parent
df7a39776d
commit
8c996a75ef
@ -36,6 +36,20 @@ const noteEditor = (function() {
|
||||
isNoteChanged = true;
|
||||
}
|
||||
|
||||
async function reload() {
|
||||
// no saving here
|
||||
|
||||
await loadNoteToEditor(getCurrentNoteId());
|
||||
}
|
||||
|
||||
async function switchToNote(noteId) {
|
||||
if (getCurrentNoteId() !== noteId) {
|
||||
await saveNoteIfChanged();
|
||||
|
||||
await loadNoteToEditor(noteId);
|
||||
}
|
||||
}
|
||||
|
||||
async function saveNoteIfChanged() {
|
||||
if (!isNoteChanged) {
|
||||
return;
|
||||
@ -247,6 +261,8 @@ const noteEditor = (function() {
|
||||
setInterval(saveNoteIfChanged, 5000);
|
||||
|
||||
return {
|
||||
reload,
|
||||
switchToNote,
|
||||
saveNoteIfChanged,
|
||||
updateNoteFromInputs,
|
||||
saveNoteToServer,
|
||||
|
@ -107,7 +107,7 @@ const noteTree = (function() {
|
||||
activate: (event, data) => {
|
||||
const node = data.node.data;
|
||||
|
||||
noteEditor.saveNoteIfChanged().then(() => noteEditor.loadNoteToEditor(node.note_id));
|
||||
noteEditor.switchToNote(node.note_id);
|
||||
},
|
||||
expand: (event, data) => {
|
||||
setExpandedToServer(data.node.key, true);
|
||||
@ -119,8 +119,6 @@ const noteTree = (function() {
|
||||
if (startNoteId) {
|
||||
data.tree.activateKey(startNoteId);
|
||||
}
|
||||
|
||||
$(window).resize();
|
||||
},
|
||||
hotkeys: {
|
||||
keydown: keybindings
|
||||
|
@ -1,8 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
const status = (function() {
|
||||
const treeEl = $("#tree");
|
||||
const $changesToPushCountEl = $("#changesToPushCount");
|
||||
const changesToPushCountEl = $("#changesToPushCount");
|
||||
|
||||
async function checkStatus() {
|
||||
const resp = await $.ajax({
|
||||
@ -33,7 +32,13 @@ const status = (function() {
|
||||
noteTree.reload();
|
||||
}
|
||||
|
||||
$changesToPushCountEl.html(resp.changesToPushCount);
|
||||
if (resp.changedCurrentNote) {
|
||||
message('Reloading note because background change');
|
||||
|
||||
noteEditor.reload();
|
||||
}
|
||||
|
||||
changesToPushCountEl.html(resp.changesToPushCount);
|
||||
}
|
||||
|
||||
setInterval(checkStatus, 5 * 1000);
|
||||
|
Loading…
x
Reference in New Issue
Block a user