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

View File

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