fix collapse tree

This commit is contained in:
zadam 2021-02-04 23:08:16 +01:00
parent 6469937393
commit 397f0d1326
3 changed files with 7 additions and 4 deletions

View File

@ -763,7 +763,8 @@ export default class NoteTreeWidget extends TabAwareWidget {
const {branchIds} = await server.put(`branches/${node.data.branchId}/expanded-subtree/${isExpanded ? 1 : 0}`);
treeCache.getBranches(branchIds, true).forEach(branch => branch.isExpanded = isExpanded);
treeCache.getBranches(branchIds, true)
.forEach(branch => branch.isExpanded = !!isExpanded);
await this.batchUpdate(async () => {
await node.load(true);

View File

@ -121,7 +121,8 @@ function moveBranchAfterNote(req) {
}
function setExpanded(req) {
const {branchId, expanded} = req.params;
const {branchId} = req.params;
const expanded = parseInt(req.params.expanded);
if (branchId !== 'root') {
sql.execute("UPDATE branches SET isExpanded = ? WHERE branchId = ?", [expanded, branchId]);
@ -137,7 +138,8 @@ function setExpanded(req) {
}
function setExpandedForSubtree(req) {
const {branchId, expanded} = req.params;
const {branchId} = req.params;
const expanded = parseInt(req.params.expanded);
let branchIds = sql.getColumn(`
WITH RECURSIVE

View File

@ -22,7 +22,7 @@ function load() {
}
for (const row of sql.iterateRows(`SELECT branchId, noteId, parentNoteId, prefix, notePosition, isExpanded FROM branches WHERE isDeleted = 0`, [])) {
new Branch(noteCache, row);
const branch = new Branch(noteCache, row);
}
for (const row of sql.iterateRows(`SELECT attributeId, noteId, type, name, value, isInheritable, position FROM attributes WHERE isDeleted = 0`, [])) {