improve performance when quickly switching notes (by e.g. holding down arrow in the tree)

This commit is contained in:
azivner
2018-10-31 19:08:31 +01:00
parent 5872146172
commit 63edde8a73
2 changed files with 18 additions and 5 deletions

View File

@@ -164,7 +164,19 @@ async function handleProtectedSession() {
}
async function loadNoteDetail(noteId) {
currentNote = await loadNote(noteId);
const loadedNote = await loadNote(noteId);
// we will try to render the new note only if it's still the active one in the tree
// this is useful when user quickly switches notes (by e.g. holding down arrow) so that we don't
// try to render all those loaded notes one after each other. This only guarantees that correct note
// will be displayed independent of timing
const currentTreeNode = treeService.getCurrentNode();
if (currentTreeNode && currentTreeNode.data.noteId !== loadedNote.noteId) {
return;
}
currentNote = loadedNote;
refreshAttributes(); // needs to happend after loading the note itself because it references current noteId
if (isNewNoteCreated) {