simplify error rendering logic
This commit is contained in:
parent
0c98930d4c
commit
bbdbe7e599
@ -38,7 +38,7 @@ export class RelativeScale {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (max === Number.MAX_VALUE) {
|
if (max === Number.MIN_VALUE) {
|
||||||
max = 0
|
max = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,22 +244,20 @@ export class ServerRegistration {
|
|||||||
const playerCountLabelElement = document.getElementById('player-count_' + this.serverId)
|
const playerCountLabelElement = document.getElementById('player-count_' + this.serverId)
|
||||||
const errorElement = document.getElementById('error_' + this.serverId)
|
const errorElement = document.getElementById('error_' + this.serverId)
|
||||||
|
|
||||||
if (ping.error || typeof ping.playerCount !== 'number') {
|
if (ping.error) {
|
||||||
// Hide any visible player-count and show the error element
|
// Hide any visible player-count and show the error element
|
||||||
playerCountLabelElement.style.display = 'none'
|
playerCountLabelElement.style.display = 'none'
|
||||||
errorElement.style.display = 'block'
|
errorElement.style.display = 'block'
|
||||||
|
|
||||||
let errorMessage
|
errorElement.innerText = ping.error.message
|
||||||
|
} else if (typeof ping.playerCount !== 'number') {
|
||||||
|
// Hide any visible player-count and show the error element
|
||||||
|
playerCountLabelElement.style.display = 'none'
|
||||||
|
errorElement.style.display = 'block'
|
||||||
|
|
||||||
if (ping.error) {
|
// If the frontend has freshly connection, and the server's last ping was in error, it may not contain an error object
|
||||||
errorMessage = ping.error.message
|
// In this case playerCount will safely be null, so provide a generic error message instead
|
||||||
} else if (typeof ping.playerCount !== 'number') {
|
errorElement.innerText = 'Failed to ping'
|
||||||
// If the frontend has freshly connection, and the server's last ping was in error, it may not contain an error object
|
|
||||||
// In this case playerCount will safely be null, so provide a generic error message instead
|
|
||||||
errorMessage = 'Failed to ping'
|
|
||||||
}
|
|
||||||
|
|
||||||
errorElement.innerText = errorMessage
|
|
||||||
} else if (typeof ping.playerCount === 'number') {
|
} else if (typeof ping.playerCount === 'number') {
|
||||||
// Ensure the player-count element is visible and hide the error element
|
// Ensure the player-count element is visible and hide the error element
|
||||||
playerCountLabelElement.style.display = 'block'
|
playerCountLabelElement.style.display = 'block'
|
||||||
|
Loading…
Reference in New Issue
Block a user