Skip to content

Commit

Permalink
reduce flickering while hoisted
Browse files Browse the repository at this point in the history
  • Loading branch information
zadam committed Nov 6, 2023
1 parent 40fb6aa commit b700f06
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/public/app/widgets/note_tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
}
});

await this.filterHoistedBranch();
await this.filterHoistedBranch(true);

// don't activate the active note, see discussion in https://github.com/zadam/trilium/issues/3664
}
Expand Down Expand Up @@ -1021,7 +1021,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
}
}

this.filterHoistedBranch();
this.filterHoistedBranch(false);
}

async refreshSearch(e) {
Expand Down Expand Up @@ -1080,7 +1080,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
}
}, false);

this.filterHoistedBranch();
this.filterHoistedBranch(true);
}, 600 * 1000);
}

Expand Down Expand Up @@ -1112,7 +1112,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {

if (refreshCtx.noteIdsToReload.size > 0 || refreshCtx.noteIdsToUpdate.size > 0) {
// workaround for https://github.com/mar10/fancytree/issues/1054
this.filterHoistedBranch();
this.filterHoistedBranch(true);
}
}

Expand Down Expand Up @@ -1371,7 +1371,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
await this.tree.reload([rootNode]);
});

await this.filterHoistedBranch();
await this.filterHoistedBranch(true);

if (activeNotePath) {
const node = await this.getNodeFromPath(activeNotePath, true);
Expand All @@ -1384,16 +1384,25 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {

async hoistedNoteChangedEvent({ntxId}) {
if (this.isNoteContext(ntxId)) {
await this.filterHoistedBranch();
await this.filterHoistedBranch(true);
}
}

async filterHoistedBranch() {
async filterHoistedBranch(forceUpdate = false) {
if (!this.noteContext) {
return;
}

const hoistedNotePath = await treeService.resolveNotePath(this.noteContext.hoistedNoteId);

if (!forceUpdate && this.lastFilteredHoistedNotePath === hoistedNotePath) {
// no need to re-filter if the hoisting did not change
// (helps with flickering on simple note change with large subtrees)
return;
}

this.lastFilteredHoistedNotePath = hoistedNotePath;

await this.getNodeFromPath(hoistedNotePath);

if (this.noteContext.hoistedNoteId === 'root') {
Expand Down

0 comments on commit b700f06

Please sign in to comment.