Fixed initial node when visiting page
This commit is contained in:
parent
303c7d9b2d
commit
b1c85d96e9
3 changed files with 29 additions and 17 deletions
|
|
@ -11,12 +11,22 @@ export class App {
|
|||
this.crumbsElement = document.getElementById('crumbs')
|
||||
this.nodeUI = document.getElementById('note')
|
||||
|
||||
|
||||
_mbus.subscribe('TREE_TRUNK_FETCHED', async () => {
|
||||
document.getElementById('tree').append(this.tree.render())
|
||||
// Subscribing to the start node existing after the tree trunk is
|
||||
// fetched since the NODE_COMPONENT_EXIST message isn't sent for the
|
||||
// root node itself, and the root node should be selected in the tree
|
||||
// after it is rendered when the site is shown without UUID in the URL.
|
||||
const startNode = await this.getStartNode()
|
||||
_mbus.subscribe(`NODE_COMPONENT_EXIST_${startNode.UUID}`, () => {
|
||||
this.goToNode(startNode.UUID, false, false)
|
||||
})
|
||||
|
||||
document.getElementById('tree').append(await this.tree.render())
|
||||
document.getElementById('tree-nodes')?.focus()
|
||||
|
||||
const startNode = await this.getStartNode()
|
||||
this.goToNode(startNode.UUID, false, false)
|
||||
if (startNode.UUID == ROOT_NODE)
|
||||
this.goToNode(startNode.UUID, false, false)
|
||||
})
|
||||
|
||||
_mbus.subscribe('TREE_NODE_SELECTED', event => {
|
||||
|
|
@ -41,7 +51,7 @@ export class App {
|
|||
if (e.startsWith('page-'))
|
||||
classList.remove(e)
|
||||
})
|
||||
classList.add('page-'+page)
|
||||
classList.add('page-' + page)
|
||||
})
|
||||
|
||||
window.addEventListener('keydown', event => this.keyHandler(event))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue