remove timeout tasks since updates occur in bulk now
This commit is contained in:
parent
63a01ace95
commit
4104c4144a
@ -62,8 +62,6 @@ export class App {
|
||||
|
||||
initTasks () {
|
||||
this._taskIds.push(setInterval(this.sortController.sortServers, 5000))
|
||||
this._taskIds.push(setInterval(this.updateGlobalStats, 1000))
|
||||
this._taskIds.push(setInterval(this.percentageBar.redraw, 1000))
|
||||
}
|
||||
|
||||
handleDisconnect () {
|
||||
|
@ -161,18 +161,6 @@ export class GraphDisplayManager {
|
||||
document.getElementById('settings-toggle').style.display = 'inline-block'
|
||||
}
|
||||
|
||||
// requestRedraw allows usages to request a redraw that may be performed, or cancelled, sometime later
|
||||
// This allows multiple rapid, but individual updates, to clump into a single redraw instead
|
||||
requestRedraw () {
|
||||
if (this._redrawRequestTimeout) {
|
||||
clearTimeout(this._redrawRequestTimeout)
|
||||
}
|
||||
|
||||
// Schedule new delayed redraw call
|
||||
// This can be cancelled by #requestRedraw, #redraw and #reset
|
||||
this._redrawRequestTimeout = setTimeout(this.redraw, 1000)
|
||||
}
|
||||
|
||||
redraw = () => {
|
||||
// Use drawing as a hint to update settings
|
||||
// This may cause unnessecary localStorage updates, but its a rare and harmless outcome
|
||||
@ -183,14 +171,6 @@ export class GraphDisplayManager {
|
||||
this._plotInstance.setData(this.getVisibleGraphData())
|
||||
this._plotInstance.setupGrid()
|
||||
this._plotInstance.draw()
|
||||
|
||||
// undefine value so #clearTimeout is not called
|
||||
// This is safe even if #redraw is manually called since it removes the pending work
|
||||
if (this._redrawRequestTimeout) {
|
||||
clearTimeout(this._redrawRequestTimeout)
|
||||
}
|
||||
|
||||
this._redrawRequestTimeout = undefined
|
||||
}
|
||||
|
||||
requestResize () {
|
||||
@ -348,12 +328,6 @@ export class GraphDisplayManager {
|
||||
this._resizeRequestTimeout = undefined
|
||||
}
|
||||
|
||||
if (this._redrawRequestTimeout) {
|
||||
clearTimeout(this._redrawRequestTimeout)
|
||||
|
||||
this._redrawRequestTimeout = undefined
|
||||
}
|
||||
|
||||
// Reset modified DOM structures
|
||||
document.getElementById('big-graph-checkboxes').innerHTML = ''
|
||||
document.getElementById('big-graph-controls').style.display = 'none'
|
||||
|
@ -82,6 +82,8 @@ export class SocketManager {
|
||||
break
|
||||
|
||||
case 'updateServers': {
|
||||
let requestGraphRedraw = false
|
||||
|
||||
for (let serverId = 0; serverId < payload.updates.length; serverId++) {
|
||||
// The backend may send "update" events prior to receiving all "add" events
|
||||
// A server has only been added once it's ServerRegistration is defined
|
||||
@ -105,10 +107,19 @@ export class SocketManager {
|
||||
|
||||
// Only redraw the graph if not mutating hidden data
|
||||
if (serverRegistration.isVisible) {
|
||||
this._app.graphDisplayManager.requestRedraw()
|
||||
requestGraphRedraw = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Run redraw tasks after handling bulk updates
|
||||
if (requestGraphRedraw) {
|
||||
this._app.graphDisplayManager.redraw()
|
||||
}
|
||||
|
||||
this._app.percentageBar.redraw()
|
||||
this._app.updateGlobalStats()
|
||||
|
||||
break
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user