Sync shows/disappears

This commit is contained in:
Magnus Åhall 2026-06-09 17:03:01 +02:00
parent 25b763703d
commit 1f24f1f2f2
4 changed files with 67 additions and 44 deletions

View file

@ -4,19 +4,33 @@
.heading-container { .heading-container {
display: grid; display: grid;
grid-template-columns: min-content 1fr; grid-template-columns: min-content 1fr;
grid-gap: 16px; grid-gap: 12px;
white-space: nowrap; white-space: nowrap;
align-items: center; align-items: center;
margin-top: 32px; margin-bottom: 16px;
margin-bottom: 8px;
&:first-child { &:first-child {
margin-top: 32px; margin-top: 32px !important;
.line {
display: none !important;
}
} }
.line { .line {
border-bottom: 1px solid var(--line-color); border-bottom: 1px solid var(--line-color);
} }
&[data-heading="1"] {
margin-top: 64px;
}
&[data-heading="2"],
&[data-heading="3"] {
margin-top: 16px;
.line {
display: none;
}
} }
h1 { h1 {
@ -25,10 +39,11 @@
display: inline-block; display: inline-block;
font-size: 1.25em; font-size: 1.25em;
border-radius: 8px; clip-path: polygon(0 0, 100% 0, calc(100% - 16px) 100%, 0 100%);
color: #fff; color: #fff;
background-color: var(--color1); background-color: var(--color1);
padding: 4px 12px; padding: 4px 24px 4px 16px;
margin-top: 0px; margin-top: 0px;
margin-bottom: 0px; margin-bottom: 0px;
@ -37,21 +52,22 @@
h2 { h2 {
font-size: 1.25em; font-size: 1.25em;
margin-top: 0px; margin-top: 16px;
margin-bottom: 0px; margin-bottom: 0px;
color: var(--color1); color: var(--color1);
} }
h2+.line, h3 {
h3+.line { margin: 0;
border-bottom: none !important;
}
h3:before { &:before {
font-size: 1.0em; font-size: 1.0em;
content: "> "; content: "> ";
color: var(--color1); color: var(--color1);
} }
}
}
a { a {
color: var(--color1); color: var(--color1);

View file

@ -307,7 +307,8 @@ button {
} }
n2-syncprogress { n2-syncprogress {
position: absolute; display: grid;
position: fixed;
top: 8px; top: 8px;
right: 8px; right: 8px;
padding: 8px 16px; padding: 8px 16px;
@ -316,8 +317,15 @@ n2-syncprogress {
font-weight: bold; font-weight: bold;
background-color: var(--color1); background-color: var(--color1);
color: #fff; color: #fff;
box-shadow: rgba(0, 0, 0, 0.1) 0px 10px 15px -3px, rgba(0, 0, 0, 0.05) 0px 4px 6px -2px;
opacity: 0;
transition: opacity 250ms;
&.show {
opacity: 1;
}
display: grid;
grid-template-columns: min-content repeat(3, min-content); grid-template-columns: min-content repeat(3, min-content);
grid-gap: 8px 8px; grid-gap: 8px 8px;
white-space: nowrap; white-space: nowrap;

View file

@ -115,7 +115,7 @@ export class MarkedPosition {
heading(token) { heading(token) {
const content = this.parser.parseInline(token.tokens) const content = this.parser.parseInline(token.tokens)
return ` return `
<div class="heading-container"> <div class="heading-container" data-heading="${token.depth}">
<h${token.depth} ondblclick="setpos(event)" data-offset-start="${token.position.start.offset}" data-offset-end="${token.position.end.offset}">${content}</h${token.depth}>\n <h${token.depth} ondblclick="setpos(event)" data-offset-start="${token.position.start.offset}" data-offset-end="${token.position.end.offset}">${content}</h${token.depth}>\n
<div class="line"></div>\n <div class="line"></div>\n
</div> </div>

View file

@ -19,7 +19,6 @@ export class Sync {
let nodeCountDownload = await this.getNodeCount(oldMax) let nodeCountDownload = await this.getNodeCount(oldMax)
let nodeCountUpload = await nodeStore.sendQueue.count() let nodeCountUpload = await nodeStore.sendQueue.count()
console.log(nodeCountUpload)
_mbus.dispatch('SYNC_DOWNLOAD_COUNT', { count: nodeCountDownload }) _mbus.dispatch('SYNC_DOWNLOAD_COUNT', { count: nodeCountDownload })
_mbus.dispatch('SYNC_UPLOAD_COUNT', { count: nodeCountUpload }) _mbus.dispatch('SYNC_UPLOAD_COUNT', { count: nodeCountUpload })
@ -81,11 +80,11 @@ export class Sync {
handled++ handled++
if (handled % 100 === 0) if (handled % 100 === 0)
_mbus.dispatch('SYNC_HANDLED', { handled }) _mbus.dispatch('SYNC_DOWNLOADED', { handled })
} }
} while (res.Continue) } while (res.Continue)
_mbus.dispatch('SYNC_HANDLED', { handled }) _mbus.dispatch('SYNC_DOWNLOADED', { handled })
nodeStore.setAppState('latest_sync_node', currMax) nodeStore.setAppState('latest_sync_node', currMax)
} catch (e) { } catch (e) {
@ -178,11 +177,12 @@ export class N2SyncProgress extends CustomHTMLElement {
super() super()
this.reset() this.reset()
_mbus.subscribe('SYNC_DOWNLOAD_COUNT', event => this.progressHandler(event)) _mbus.subscribe('SYNC_DOWNLOAD_COUNT', event => this.progressHandler(event))
_mbus.subscribe('SYNC_UPLOAD_COUNT', event => this.progressHandler(event)) _mbus.subscribe('SYNC_UPLOAD_COUNT', event => this.progressHandler(event))
_mbus.subscribe('SYNC_HANDLED', event => this.progressHandler(event)) _mbus.subscribe('SYNC_DOWNLOADED', event => this.progressHandler(event))
_mbus.subscribe('SYNC_DONE', event => this.progressHandler(event))
_mbus.subscribe('SYNC_UPLOADED', event => this.progressHandler(event)) _mbus.subscribe('SYNC_UPLOADED', event => this.progressHandler(event))
_mbus.subscribe('SYNC_DONE', event => this.progressHandler(event))
}//}}} }//}}}
reset() {//{{{ reset() {//{{{
this.state = { this.state = {
@ -205,11 +205,14 @@ export class N2SyncProgress extends CustomHTMLElement {
this.setSyncState(true) this.setSyncState(true)
break break
case 'SYNC_HANDLED': case 'SYNC_DOWNLOADED':
console.log('SYNC_HANDLED', eventData.handled)
this.state.nodesSynced = eventData.handled this.state.nodesSynced = eventData.handled
break break
case 'SYNC_UPLOADED':
this.state.nodesUploaded += eventData.count
break
case 'SYNC_DONE': case 'SYNC_DONE':
// Hides the progress bar. // Hides the progress bar.
this.setSyncState(false) this.setSyncState(false)
@ -221,10 +224,6 @@ export class N2SyncProgress extends CustomHTMLElement {
// Reload the tree nodes to reflect the new/updated nodes. // Reload the tree nodes to reflect the new/updated nodes.
window._app.tree.reset() window._app.tree.reset()
break break
case 'SYNC_UPLOADED':
this.state.nodesUploaded += eventData.count
break
} }
this.render() this.render()
}//}}} }//}}}