Fixed tree reset after sync, optimized sync with IndexedDB

This commit is contained in:
Magnus Åhall 2026-05-03 19:45:39 +02:00
parent 454d065baa
commit 26ca510785
5 changed files with 72 additions and 52 deletions

View file

@ -10,6 +10,7 @@ export class N2Tree extends CustomHTMLElement {
<img data-el="search" class='search' src="/images/${_VERSION}/icon_search.svg" style="height: 22px" />
<img data-el="sync" class='sync' src="/images/${_VERSION}/icon_refresh.svg" />
</div>
<div data-el="treenodes"></div>
`
}// }}}
@ -39,12 +40,20 @@ export class N2Tree extends CustomHTMLElement {
for (const node of this.treeTrunk) {
const treenode = new N2TreeNode(this, node)
this.treeNodeComponents[node.UUID] = treenode
this.appendChild(treenode.render())
this.elTreenodes.appendChild(treenode.render())
}
this.rendered = true
return this
}// }}}
reset() {
console.log('tree reset')
this.treeNodeComponents = {}
this.treeTrunk = []
this.rendered = false
this.elTreenodes.replaceChildren()
this.populateFirstLevel()
}
populateFirstLevel() {//{{{
nodeStore.get(ROOT_NODE)
.then(node => node.fetchChildren())