fixes to stable sorting

This commit is contained in:
zadam
2023-11-03 01:11:47 +01:00
parent 45ed436426
commit f37f47ce5b
9 changed files with 23 additions and 20 deletions

View File

@@ -1147,7 +1147,6 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
let parentsOfAddedNodes = [];
const allBranchRows = loadResults.getBranchRows();
// TODO: this flag is suspicious - why does it matter that all branches in a particular update are deleted?
const allBranchesDeleted = allBranchRows.every(branchRow => !!branchRow.isDeleted);
for (const branchRow of allBranchRows) {
@@ -1190,12 +1189,16 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
continue;
}
const found = (parentNode.getChildren() || []).find(child => child.data.noteId === branchRow.noteId);
if (!found) {
const note = await froca.getNote(branchRow.noteId);
const frocaBranch = froca.getBranch(branchRow.branchId);
const foundNode = (parentNode.getChildren() || []).find(child => child.data.noteId === branchRow.noteId);
if (foundNode) {
// the branch already exists in the tree
if (branchRow.isExpanded !== foundNode.isExpanded()) {
noteIdsToReload.add(frocaBranch.noteId);
}
} else {
// make sure it's loaded
const note = await froca.getNote(branchRow.noteId);
const frocaBranch = froca.getBranch(branchRow.branchId);
// we're forcing lazy since it's not clear if the whole required subtree is in froca
parentNode.addChildren([this.prepareNode(frocaBranch, true)]);