Reload tree after sync

This commit is contained in:
Magnus Åhall 2025-01-22 21:35:37 +01:00
parent 02a8e10d11
commit 0bd5d08edf
3 changed files with 36 additions and 6 deletions

View file

@ -9,6 +9,7 @@ export class Notes2 extends Component {
constructor() {//{{{
super()
this.nodeUI = createRef()
this.reloadTree = signal(0)
this.state = {
startNode: null,
}
@ -19,11 +20,15 @@ export class Notes2 extends Component {
this.getStartNode()
}//}}}
render(_props, { startNode }) {//{{{
console.log('notes2 render')
const treeKey = `tree-${this.reloadTree}`
console.log('treeKey', treeKey)
if (startNode === null)
return
return html`
<${Tree} app=${this} startNode=${startNode} />
<${Tree} app=${this} key=${treeKey} startNode=${startNode} />
<div id="nodeui">
<${NodeUI} app=${this} ref=${this.nodeUI} startNode=${startNode} />
@ -69,6 +74,7 @@ export class Notes2 extends Component {
class Tree extends Component {
constructor(props) {//{{{
super(props)
console.log('new tree')
this.treeNodeComponents = {}
this.treeTrunk = []
this.selectedNode = null
@ -89,6 +95,14 @@ class Tree extends Component {
${renderedTreeTrunk}
</div>`
}//}}}
componentDidMount() {//{{{
// This will show and select the treenode that is selected in the node UI.
const node = _notes2.current?.nodeUI.current?.node.value
if (node === null)
return
_notes2.current.tree.expandToTrunk(node)
this.setSelected(node)
}//}}}
populateFirstLevel(callback = null) {//{{{
nodeStore.getTreeNodes('', 0)