diff --git a/node.go b/node.go index 0beb1b1..c8afe94 100644 --- a/node.go +++ b/node.go @@ -54,10 +54,6 @@ type Node struct { Content string ContentEncrypted string `db:"content_encrypted" json:"-"` Markdown bool - - // CryptoKeyID int `db:"crypto_key_id"` - //Files []File - //ChecklistGroups []ChecklistGroup } func NodeTree(userID, offset int, synced uint64) (nodes []TreeNode, maxSeq uint64, moreRowsExist bool, err error) { // {{{ diff --git a/static/css/markdown.css b/static/css/markdown.css index 85cde2c..1ecbc94 100644 --- a/static/css/markdown.css +++ b/static/css/markdown.css @@ -22,6 +22,7 @@ &[data-heading="1"] { margin-top: 64px; + margin-bottom: 32px; } &[data-heading="2"], @@ -33,6 +34,10 @@ } } + h1, h2, h3 { + margin: 0; + } + h1 { border-bottom: 1px solid #ccc; @@ -45,21 +50,14 @@ background-color: var(--color1); padding: 4px 24px 4px 16px; - margin-top: 0px; - margin-bottom: 0px; - } h2 { font-size: 1.25em; - margin-top: 16px; - margin-bottom: 0px; color: var(--color1); } h3 { - margin: 0; - &:before { font-size: 1.0em; content: "> "; @@ -85,7 +83,7 @@ table { border: 1px solid #ccc; border-collapse: collapse; - margin-top: 14px; + margin-top: 16px; th { text-align: left; diff --git a/static/css/notes2.css b/static/css/notes2.css index 76c660b..44618cf 100644 --- a/static/css/notes2.css +++ b/static/css/notes2.css @@ -326,6 +326,10 @@ n2-syncprogress { opacity: 1; } + &.ok { + background-color: #5aa02c; + } + grid-template-columns: min-content repeat(3, min-content); grid-gap: 8px 8px; white-space: nowrap; diff --git a/static/js/sidebar.mjs b/static/js/sidebar.mjs index da05750..23c78c0 100644 --- a/static/js/sidebar.mjs +++ b/static/js/sidebar.mjs @@ -117,7 +117,6 @@ export class N2Sidebar extends CustomHTMLElement { this.tabIndex = 0 this.treeNodeComponents = {} - this.treeTrunk = [] this.expandedNodes = {} // keyed on UUID this.selectedNode = null this.rendered = false @@ -170,10 +169,9 @@ export class N2Sidebar extends CustomHTMLElement { }// }}} reset() {// {{{ this.treeNodeComponents = {} - this.treeTrunk = [] this.rendered = false this.elTreenodes.replaceChildren() - this.populateFirstLevel() + this.render() }// }}} getNodeExpanded(UUID) {//{{{ if (this.expandedNodes[UUID] === undefined) diff --git a/static/js/sync.mjs b/static/js/sync.mjs index f0c9296..35485eb 100644 --- a/static/js/sync.mjs +++ b/static/js/sync.mjs @@ -20,6 +20,7 @@ export class Sync { let nodeCountDownload = await this.getNodeCount(oldMax) let nodeCountUpload = await nodeStore.sendQueue.count() + _mbus.dispatch('SYNC_START') _mbus.dispatch('SYNC_DOWNLOAD_COUNT', { count: nodeCountDownload }) _mbus.dispatch('SYNC_UPLOAD_COUNT', { count: nodeCountUpload }) @@ -175,9 +176,8 @@ export class N2SyncProgress extends CustomHTMLElement { }// }}} constructor() {//{{{ super() - this.reset() - + _mbus.subscribe('SYNC_START', () => this.reset()) _mbus.subscribe('SYNC_DOWNLOAD_COUNT', event => this.progressHandler(event)) _mbus.subscribe('SYNC_UPLOAD_COUNT', event => this.progressHandler(event)) _mbus.subscribe('SYNC_DOWNLOADED', event => this.progressHandler(event)) @@ -185,12 +185,14 @@ export class N2SyncProgress extends CustomHTMLElement { _mbus.subscribe('SYNC_DONE', event => this.progressHandler(event)) }//}}} reset() {//{{{ + this.classList.remove('ok') this.state = { nodesToDownload: 0, nodesToUpload: 0, - nodesSynced: 0, + nodesDowloaded: 0, nodesUploaded: 0, } + this.render() }//}}} progressHandler(event) {//{{{ const eventData = event.detail.data @@ -206,7 +208,7 @@ export class N2SyncProgress extends CustomHTMLElement { break case 'SYNC_DOWNLOADED': - this.state.nodesSynced = eventData.handled + this.state.nodesDowloaded = eventData.handled break case 'SYNC_UPLOADED': @@ -214,23 +216,26 @@ export class N2SyncProgress extends CustomHTMLElement { break case 'SYNC_DONE': + this.classList.add('ok') + // Hides the progress bar. this.setSyncState(false) // Don't update anything if nothing was synced. - if (this.state.nodesSynced === 0) + if (this.state.nodesDowloaded === 0) break // Reload the tree nodes to reflect the new/updated nodes. - window._app.tree.reset() + window._app.sidebar.reset() break } this.render() }//}}} render() {//{{{ - this.elDownloadTransferred.innerText = this.state.nodesSynced + this.elDownloadTransferred.innerText = this.state.nodesDowloaded this.elDownloadTotal.innerText = this.state.nodesToDownload + console.log('setting elUploadTransferred', this.state.nodesUploaded) this.elUploadTransferred.innerText = this.state.nodesUploaded this.elUploadTotal.innerText = this.state.nodesToUpload }//}}} @@ -238,6 +243,7 @@ export class N2SyncProgress extends CustomHTMLElement { if (state) this.classList.add('show') else + // Give the user a chance to see what it ended on. setTimeout(() => this.classList.remove('show'), 1500) }// }}} }