simplify addServer/pingHistory & placeholder generation prior to optimizations
This commit is contained in:
@ -113,17 +113,6 @@ class ServerRegistration {
|
||||
|
||||
getPingHistory () {
|
||||
if (this._pingHistory.length > 0) {
|
||||
const pingHistory = []
|
||||
|
||||
for (let i = 0; i < this._pingHistory.length - 1; i++) {
|
||||
pingHistory[i] = this._pingHistory[i]
|
||||
}
|
||||
|
||||
// Insert the latest update manually into the array
|
||||
// This is a mutated copy of the last update to contain live metadata
|
||||
// The metadata is used by the frontend for rendering
|
||||
const lastPing = this._pingHistory[this._pingHistory.length - 1]
|
||||
|
||||
const payload = {
|
||||
versions: this.versions,
|
||||
recordData: this.recordData,
|
||||
@ -138,6 +127,11 @@ class ServerRegistration {
|
||||
payload.graphPeakData = graphPeakData
|
||||
}
|
||||
|
||||
// Insert the latest update manually into the array
|
||||
// This is a mutated copy of the last update to contain live metadata
|
||||
// The metadata is used by the frontend for rendering
|
||||
const lastPing = this._pingHistory[this._pingHistory.length - 1]
|
||||
|
||||
// Conditionally append to avoid defining fields with undefined values
|
||||
if (lastPing.result) {
|
||||
payload.result = lastPing.result
|
||||
@ -145,21 +139,20 @@ class ServerRegistration {
|
||||
payload.error = lastPing.error
|
||||
}
|
||||
|
||||
// Insert the reconstructed update as the last entry
|
||||
// pingHistory is already sorted during its copy from _pingHistory
|
||||
pingHistory.push(payload)
|
||||
// Send a copy of pingHistory
|
||||
// Omit the last value since it is contained within payload
|
||||
payload.pingHistory = this._pingHistory.slice(0, this._pingHistory.length - 1)
|
||||
|
||||
return pingHistory
|
||||
return payload
|
||||
}
|
||||
|
||||
return [{
|
||||
return {
|
||||
error: {
|
||||
message: 'Waiting...',
|
||||
placeholder: true
|
||||
message: 'Pinging...'
|
||||
},
|
||||
recordData: this.recordData,
|
||||
graphPeakData: this.getGraphPeak()
|
||||
}]
|
||||
}
|
||||
}
|
||||
|
||||
loadGraphPoints (points) {
|
||||
|
Reference in New Issue
Block a user