Compare commits
4 commits
697576cb34
...
dc7e70b3f2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dc7e70b3f2 | ||
|
|
cdccbc9306 | ||
|
|
92287e2076 | ||
|
|
48ac1a8044 |
4 changed files with 11 additions and 21 deletions
2
main.go
2
main.go
|
|
@ -23,7 +23,7 @@ import (
|
|||
"text/template"
|
||||
)
|
||||
|
||||
const VERSION = "v16"
|
||||
const VERSION = "v17"
|
||||
const CONTEXT_USER = 1
|
||||
const SYNC_PAGINATION = 200
|
||||
|
||||
|
|
|
|||
|
|
@ -10,25 +10,23 @@ export class App {
|
|||
this.crumbs = new N2Crumbs()
|
||||
this.crumbsElement = document.getElementById('crumbs')
|
||||
this.nodeUI = document.getElementById('note')
|
||||
this.showNodeEventSequence = new ShowNodeEventSequence() // discard all GO_TO_NODE events
|
||||
|
||||
this.sidebar.render().then(sidebar => {
|
||||
document.getElementById('tree').append(sidebar)
|
||||
document.getElementById('tree-nodes')?.focus()
|
||||
})
|
||||
|
||||
_mbus.subscribe('TREE_TRUNK_FETCHED', async () => {
|
||||
_mbus.subscribe('TREE_RENDERED', async () => {
|
||||
// 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()
|
||||
|
||||
document.getElementById('tree').append(await this.sidebar.render())
|
||||
document.getElementById('tree-nodes')?.focus()
|
||||
|
||||
if (startNode.UUID == ROOT_NODE)
|
||||
this.goToNode(startNode.UUID, false, false)
|
||||
else
|
||||
this.goToNode(startNode.UUID, false, false)
|
||||
})
|
||||
|
||||
_mbus.subscribe('TREE_NODE_SELECTED', event => {
|
||||
|
|
@ -198,7 +196,7 @@ export class App {
|
|||
await this.sidebar.makeVisible(node, ancestors, dontExpand)
|
||||
|
||||
_mbus.dispatch('CRUMBS_SET', ancestors, () => this.crumbsElement.replaceChildren(this.crumbs.render()))
|
||||
_mbus.dispatch('NODE_UI_OPEN', { node, eventSequence: this.showNodeEventSequence.next() })
|
||||
_mbus.dispatch('NODE_UI_OPEN', node)
|
||||
_mbus.dispatch('TREE_EXPANSION', { expand: false, when: 'narrow' })
|
||||
_mbus.dispatch('NODE_UNMODIFIED')
|
||||
}//}}}
|
||||
|
|
@ -208,18 +206,6 @@ export class App {
|
|||
}// }}}
|
||||
}
|
||||
|
||||
class ShowNodeEventSequence {
|
||||
constructor() {
|
||||
this.seq = 0
|
||||
}
|
||||
next() {
|
||||
return ++this.seq
|
||||
}
|
||||
current() {
|
||||
return this.seq
|
||||
}
|
||||
}
|
||||
|
||||
class N2Crumbs extends CustomHTMLElement {
|
||||
static {// {{{
|
||||
this.tmpl = document.createElement('template')
|
||||
|
|
|
|||
|
|
@ -42,8 +42,7 @@ export class N2PageNodeUI extends CustomHTMLElement {
|
|||
this.marked = new MarkedPosition()
|
||||
|
||||
_mbus.subscribe('NODE_UI_OPEN', event => {
|
||||
console.log(event.detail.data.eventSequence, _app.showNodeEventSequence.current())
|
||||
this.node = event.detail.data.node
|
||||
this.node = event.detail.data
|
||||
this.showMarkdown(true)
|
||||
this.render()
|
||||
})
|
||||
|
|
|
|||
|
|
@ -160,6 +160,11 @@ export class N2Sidebar extends CustomHTMLElement {
|
|||
this.treeNodeComponents[startnode.UUID] = starttreenode
|
||||
this.elTreenodes.appendChild(await starttreenode.render())
|
||||
|
||||
// Notify the application that the initial tree is rendered (with children)
|
||||
// and that initial node selection can take place. App will check URL to
|
||||
// select the correct one.
|
||||
_mbus.dispatch('TREE_RENDERED')
|
||||
|
||||
this.rendered = true
|
||||
return this
|
||||
}// }}}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue