fix note tree flickering (note cache was not updated when expanded status changed)

This commit is contained in:
zadam
2021-02-04 22:05:32 +01:00
parent 48cb4d2ab9
commit 6469937393
5 changed files with 32 additions and 12 deletions

View File

@@ -5,6 +5,7 @@ const utils = require('../../services/utils');
const entityChangesService = require('../../services/entity_changes.js');
const treeService = require('../../services/tree');
const noteService = require('../../services/notes');
const noteCache = require('../../services/note_cache/note_cache');
const repository = require('../../services/repository');
const TaskContext = require('../../services/task_context');
@@ -126,6 +127,12 @@ function setExpanded(req) {
sql.execute("UPDATE branches SET isExpanded = ? WHERE branchId = ?", [expanded, branchId]);
// we don't sync expanded label
// also this does not trigger updates to the frontend, this would trigger too many reloads
const branch = noteCache.branches[branchId];
if (branch) {
branch.isExpanded = !!expanded;
}
}
}
@@ -148,6 +155,14 @@ function setExpandedForSubtree(req) {
sql.executeMany(`UPDATE branches SET isExpanded = ${expanded} WHERE branchId IN (???)`, branchIds);
for (const branchId of branchIds) {
const branch = noteCache.branches[branchId];
if (branch) {
branch.isExpanded = !!expanded;
}
}
return {
branchIds
};