Compare commits
No commits in common. "25b763703d0c5d0226ad2d67d5b0ad8d1d3c68e5" and "227fa2208b5e0d7f9a90bcca9bd66e17b01016e2" have entirely different histories.
25b763703d
...
227fa2208b
3 changed files with 11 additions and 31 deletions
2
main.go
2
main.go
|
|
@ -23,7 +23,7 @@ import (
|
|||
"text/template"
|
||||
)
|
||||
|
||||
const VERSION = "v19"
|
||||
const VERSION = "v18"
|
||||
const CONTEXT_USER = 1
|
||||
const SYNC_PAGINATION = 200
|
||||
|
||||
|
|
|
|||
|
|
@ -308,8 +308,8 @@ button {
|
|||
|
||||
n2-syncprogress {
|
||||
position: absolute;
|
||||
top: 8px;
|
||||
right: 8px;
|
||||
top: 16px;
|
||||
right: 16px;
|
||||
padding: 8px 16px;
|
||||
z-index: 16384;
|
||||
border-radius: 6px;
|
||||
|
|
|
|||
|
|
@ -17,12 +17,10 @@ export class Sync {
|
|||
const state = await nodeStore.getAppState('latest_sync_node')
|
||||
const oldMax = (state?.value ? state.value : 0)
|
||||
|
||||
let nodeCountDownload = await this.getNodeCount(oldMax)
|
||||
let nodeCountUpload = await nodeStore.sendQueue.count()
|
||||
console.log(nodeCountUpload)
|
||||
let nodeCount = await this.getNodeCount(oldMax)
|
||||
nodeCount += await nodeStore.sendQueue.count()
|
||||
|
||||
_mbus.dispatch('SYNC_DOWNLOAD_COUNT', { count: nodeCountDownload })
|
||||
_mbus.dispatch('SYNC_UPLOAD_COUNT', { count: nodeCountUpload })
|
||||
_mbus.dispatch('SYNC_COUNT', { count: nodeCount })
|
||||
|
||||
await this.nodesFromServer(oldMax)
|
||||
.then(durationNodes => {
|
||||
|
|
@ -30,7 +28,6 @@ export class Sync {
|
|||
console.log(`Total time: ${Math.round(1000 * durationNodes) / 1000}s`)
|
||||
})
|
||||
|
||||
// Uploads of modified nodes to server.
|
||||
await this.nodesToServer()
|
||||
} finally {
|
||||
_mbus.dispatch('SYNC_DONE')
|
||||
|
|
@ -178,35 +175,25 @@ export class N2SyncProgress extends CustomHTMLElement {
|
|||
super()
|
||||
|
||||
this.reset()
|
||||
_mbus.subscribe('SYNC_DOWNLOAD_COUNT', event => this.progressHandler(event))
|
||||
_mbus.subscribe('SYNC_UPLOAD_COUNT', event => this.progressHandler(event))
|
||||
_mbus.subscribe('SYNC_COUNT', event => this.progressHandler(event))
|
||||
_mbus.subscribe('SYNC_HANDLED', event => this.progressHandler(event))
|
||||
_mbus.subscribe('SYNC_DONE', event => this.progressHandler(event))
|
||||
_mbus.subscribe('SYNC_UPLOADED', event => this.progressHandler(event))
|
||||
}//}}}
|
||||
reset() {//{{{
|
||||
this.state = {
|
||||
nodesToDownload: 0,
|
||||
nodesToUpload: 0,
|
||||
nodesToSync: 0,
|
||||
nodesSynced: 0,
|
||||
nodesUploaded: 0,
|
||||
}
|
||||
}//}}}
|
||||
progressHandler(event) {//{{{
|
||||
const eventData = event.detail.data
|
||||
switch (event.type) {
|
||||
case 'SYNC_DOWNLOAD_COUNT':
|
||||
this.state.nodesToDownload = eventData.count
|
||||
this.setSyncState(true)
|
||||
break
|
||||
|
||||
case 'SYNC_UPLOAD_COUNT':
|
||||
this.state.nodesToUpload = eventData.count
|
||||
case 'SYNC_COUNT':
|
||||
this.state.nodesToSync = eventData.count
|
||||
this.setSyncState(true)
|
||||
break
|
||||
|
||||
case 'SYNC_HANDLED':
|
||||
console.log('SYNC_HANDLED', eventData.handled)
|
||||
this.state.nodesSynced = eventData.handled
|
||||
break
|
||||
|
||||
|
|
@ -221,19 +208,12 @@ export class N2SyncProgress extends CustomHTMLElement {
|
|||
// Reload the tree nodes to reflect the new/updated nodes.
|
||||
window._app.tree.reset()
|
||||
break
|
||||
|
||||
case 'SYNC_UPLOADED':
|
||||
this.state.nodesUploaded += eventData.count
|
||||
break
|
||||
}
|
||||
this.render()
|
||||
}//}}}
|
||||
render() {//{{{
|
||||
this.elDownloadTransferred.innerText = this.state.nodesSynced
|
||||
this.elDownloadTotal.innerText = this.state.nodesToDownload
|
||||
|
||||
this.elUploadTransferred.innerText = this.state.nodesUploaded
|
||||
this.elUploadTotal.innerText = this.state.nodesToUpload
|
||||
this.elDownloadTotal.innerText = this.state.nodesToSync
|
||||
}//}}}
|
||||
setSyncState(state) {// {{{
|
||||
if (state)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue