Reload tree after sync
This commit is contained in:
parent
02a8e10d11
commit
0bd5d08edf
3 changed files with 36 additions and 6 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import { API } from 'api'
|
||||
import { Node } from 'node'
|
||||
import { h, Component, createRef } from 'preact'
|
||||
import { h, Component } from 'preact'
|
||||
import htm from 'htm'
|
||||
const html = htm.bind(h)
|
||||
|
||||
|
|
@ -171,14 +171,16 @@ export class Sync {
|
|||
export class SyncProgress extends Component {
|
||||
constructor() {//{{{
|
||||
super()
|
||||
|
||||
this.reset()
|
||||
}//}}}
|
||||
reset() {//{{{
|
||||
this.forceUpdateRequest = null
|
||||
|
||||
this.state = {
|
||||
nodesToSync: 0,
|
||||
nodesSynced: 0,
|
||||
syncedDone: false,
|
||||
}
|
||||
document.getElementById('sync-progress')?.classList.remove('hidden')
|
||||
}//}}}
|
||||
componentDidMount() {//{{{
|
||||
window._sync.addListener(msg => this.progressHandler(msg), true)
|
||||
|
|
@ -210,9 +212,19 @@ export class SyncProgress extends Component {
|
|||
this.state.nodesSynced += msg.count
|
||||
break
|
||||
|
||||
|
||||
case SYNC_DONE:
|
||||
// Hides the progress bar.
|
||||
this.setState({ syncedDone: true })
|
||||
|
||||
// Don't update anything if nothing was synced.
|
||||
if (this.state.nodesSynced === 0)
|
||||
break
|
||||
|
||||
// Reload the tree nodes to reflect the new/updated nodes.
|
||||
if (window._notes2?.current?.reloadTree.value !== null) {
|
||||
nodeStore.purgeCache()
|
||||
window._notes2.current.reloadTree.value = window._notes2.current.reloadTree.value + 1
|
||||
}
|
||||
break
|
||||
}
|
||||
}//}}}
|
||||
|
|
@ -228,3 +240,5 @@ export class SyncProgress extends Component {
|
|||
`
|
||||
}//}}}
|
||||
}
|
||||
|
||||
// vim: foldmethod=marker
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue