fixed race condition when changing note path in URL hash which caused flickering

This commit is contained in:
azivner 2018-01-01 18:53:52 -05:00
parent e560072f8b
commit f07c427da1
2 changed files with 13 additions and 5 deletions

View file

@ -209,8 +209,6 @@ const noteTree = (function() {
let parentNoteId = 'root';
//console.log(now(), "Run path: ", runPath);
for (const childNoteId of runPath) {
const node = getNodesByNoteId(childNoteId).find(node => node.data.parent_note_id === parentNoteId);
@ -223,6 +221,8 @@ const noteTree = (function() {
parentNoteId = childNoteId;
}
clearSelectedNodes();
}
/**
@ -391,7 +391,11 @@ const noteTree = (function() {
selectedNode.setSelected(false);
}
getCurrentNode().setSelected(true);
const currentNode = getCurrentNode();
if (currentNode) {
currentNode.setSelected(true);
}
}
function initFancyTree(noteTree) {
@ -803,7 +807,11 @@ const noteTree = (function() {
$(window).bind('hashchange', function() {
const notePath = getNotePathFromAddress();
activateNode(notePath);
if (getCurrentNotePath() !== notePath) {
console.log("Switching to " + notePath + " because of hash change");
activateNode(notePath);
}
});
if (isElectron()) {

View file

@ -175,7 +175,6 @@ div.ui-tooltip {
/* Allow to use <kbd> elements inside the title to define shortcut hints. */
.ui-menu kbd, button kbd {
float: right;
color: black;
border: none;
background-color: transparent;
@ -184,6 +183,7 @@ div.ui-tooltip {
.ui-menu kbd {
margin-left: 30px;
float: right;
}
#note-id-display {