Compare commits

..

No commits in common. "dc7e70b3f2e80f5d9e18d1f868198efe121b47e7" and "697576cb34663fc9597558117249eb7999bbf186" have entirely different histories.

4 changed files with 21 additions and 11 deletions

View file

@ -23,7 +23,7 @@ import (
"text/template"
)
const VERSION = "v17"
const VERSION = "v16"
const CONTEXT_USER = 1
const SYNC_PAGINATION = 200

View file

@ -10,23 +10,25 @@ 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_RENDERED', async () => {
_mbus.subscribe('TREE_TRUNK_FETCHED', 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 => {
@ -196,7 +198,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)
_mbus.dispatch('NODE_UI_OPEN', { node, eventSequence: this.showNodeEventSequence.next() })
_mbus.dispatch('TREE_EXPANSION', { expand: false, when: 'narrow' })
_mbus.dispatch('NODE_UNMODIFIED')
}//}}}
@ -206,6 +208,18 @@ 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')

View file

@ -42,7 +42,8 @@ export class N2PageNodeUI extends CustomHTMLElement {
this.marked = new MarkedPosition()
_mbus.subscribe('NODE_UI_OPEN', event => {
this.node = event.detail.data
console.log(event.detail.data.eventSequence, _app.showNodeEventSequence.current())
this.node = event.detail.data.node
this.showMarkdown(true)
this.render()
})

View file

@ -160,11 +160,6 @@ 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
}// }}}