Compare commits

..

No commits in common. "25b763703d0c5d0226ad2d67d5b0ad8d1d3c68e5" and "227fa2208b5e0d7f9a90bcca9bd66e17b01016e2" have entirely different histories.

3 changed files with 11 additions and 31 deletions

View file

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

View file

@ -308,8 +308,8 @@ button {
n2-syncprogress { n2-syncprogress {
position: absolute; position: absolute;
top: 8px; top: 16px;
right: 8px; right: 16px;
padding: 8px 16px; padding: 8px 16px;
z-index: 16384; z-index: 16384;
border-radius: 6px; border-radius: 6px;

View file

@ -17,12 +17,10 @@ export class Sync {
const state = await nodeStore.getAppState('latest_sync_node') const state = await nodeStore.getAppState('latest_sync_node')
const oldMax = (state?.value ? state.value : 0) const oldMax = (state?.value ? state.value : 0)
let nodeCountDownload = await this.getNodeCount(oldMax) let nodeCount = await this.getNodeCount(oldMax)
let nodeCountUpload = await nodeStore.sendQueue.count() nodeCount += await nodeStore.sendQueue.count()
console.log(nodeCountUpload)
_mbus.dispatch('SYNC_DOWNLOAD_COUNT', { count: nodeCountDownload }) _mbus.dispatch('SYNC_COUNT', { count: nodeCount })
_mbus.dispatch('SYNC_UPLOAD_COUNT', { count: nodeCountUpload })
await this.nodesFromServer(oldMax) await this.nodesFromServer(oldMax)
.then(durationNodes => { .then(durationNodes => {
@ -30,7 +28,6 @@ export class Sync {
console.log(`Total time: ${Math.round(1000 * durationNodes) / 1000}s`) console.log(`Total time: ${Math.round(1000 * durationNodes) / 1000}s`)
}) })
// Uploads of modified nodes to server.
await this.nodesToServer() await this.nodesToServer()
} finally { } finally {
_mbus.dispatch('SYNC_DONE') _mbus.dispatch('SYNC_DONE')
@ -178,35 +175,25 @@ export class N2SyncProgress extends CustomHTMLElement {
super() super()
this.reset() this.reset()
_mbus.subscribe('SYNC_DOWNLOAD_COUNT', event => this.progressHandler(event)) _mbus.subscribe('SYNC_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_HANDLED', event => this.progressHandler(event))
_mbus.subscribe('SYNC_DONE', event => this.progressHandler(event)) _mbus.subscribe('SYNC_DONE', event => this.progressHandler(event))
_mbus.subscribe('SYNC_UPLOADED', event => this.progressHandler(event))
}//}}} }//}}}
reset() {//{{{ reset() {//{{{
this.state = { this.state = {
nodesToDownload: 0, nodesToSync: 0,
nodesToUpload: 0,
nodesSynced: 0, nodesSynced: 0,
nodesUploaded: 0,
} }
}//}}} }//}}}
progressHandler(event) {//{{{ progressHandler(event) {//{{{
const eventData = event.detail.data const eventData = event.detail.data
switch (event.type) { switch (event.type) {
case 'SYNC_DOWNLOAD_COUNT': case 'SYNC_COUNT':
this.state.nodesToDownload = eventData.count this.state.nodesToSync = eventData.count
this.setSyncState(true)
break
case 'SYNC_UPLOAD_COUNT':
this.state.nodesToUpload = eventData.count
this.setSyncState(true) this.setSyncState(true)
break break
case 'SYNC_HANDLED': case 'SYNC_HANDLED':
console.log('SYNC_HANDLED', eventData.handled)
this.state.nodesSynced = eventData.handled this.state.nodesSynced = eventData.handled
break break
@ -221,19 +208,12 @@ 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()
}//}}} }//}}}
render() {//{{{ render() {//{{{
this.elDownloadTransferred.innerText = this.state.nodesSynced this.elDownloadTransferred.innerText = this.state.nodesSynced
this.elDownloadTotal.innerText = this.state.nodesToDownload this.elDownloadTotal.innerText = this.state.nodesToSync
this.elUploadTransferred.innerText = this.state.nodesUploaded
this.elUploadTotal.innerText = this.state.nodesToUpload
}//}}} }//}}}
setSyncState(state) {// {{{ setSyncState(state) {// {{{
if (state) if (state)