From 7d47e9b5f837f3affc1458342f54d0c763bdb55b Mon Sep 17 00:00:00 2001 From: Nick Krecklow Date: Wed, 29 Apr 2020 04:09:22 -0500 Subject: [PATCH] remove frontend diffing behavior since the protocol does this now --- assets/js/servers.js | 16 +++++----------- assets/js/util.js | 14 -------------- 2 files changed, 5 insertions(+), 25 deletions(-) diff --git a/assets/js/servers.js b/assets/js/servers.js index da8df03..8c530e0 100644 --- a/assets/js/servers.js +++ b/assets/js/servers.js @@ -1,4 +1,4 @@ -import { formatNumber, formatTimestamp, formatDate, formatMinecraftServerAddress, formatMinecraftVersions, isArrayEqual, isObjectEqual } from './util' +import { formatNumber, formatTimestamp, formatDate, formatMinecraftServerAddress, formatMinecraftVersions } from './util' import MISSING_FAVICON from '../images/missing_favicon.svg' @@ -84,7 +84,6 @@ export class ServerRegistration { isFavorite = false rankIndex lastRecordData - lastVersions = [] lastPeakData constructor (app, serverId, data) { @@ -175,21 +174,14 @@ export class ServerRegistration { // Otherwise the ping value is pushed into the graphData when already present this.handlePing(ping, !isInitialUpdate) - // Compare against a cached value to avoid empty updates - // Allow undefined ping.versions inside the if statement for text reset handling - if (ping.versions && !isArrayEqual(ping.versions, this.lastVersions)) { - this.lastVersions = ping.versions - + if (ping.versions) { const versionsElement = document.getElementById('version_' + this.serverId) versionsElement.style.display = 'block' versionsElement.innerText = formatMinecraftVersions(ping.versions, minecraftVersions[this.data.type]) || '' } - // Compare against a cached value to avoid empty updates - if (ping.recordData !== undefined && !isObjectEqual(ping.recordData, this.lastRecordData, ['playerCount', 'timestamp'])) { - this.lastRecordData = ping.recordData - + if (ping.recordData) { // Always set label once any record data has been received const recordLabelElement = document.getElementById('record_' + this.serverId) @@ -206,6 +198,8 @@ export class ServerRegistration { } else { recordValueElement.innerText = formatNumber(recordData.playerCount) } + + this.lastRecordData = recordData } if (ping.graphPeakData) { diff --git a/assets/js/util.js b/assets/js/util.js index e0f7932..6e55e42 100644 --- a/assets/js/util.js +++ b/assets/js/util.js @@ -135,20 +135,6 @@ export function isArrayEqual (a, b) { return true } -export function isObjectEqual (a, b, props) { - if (typeof a === 'undefined' || typeof a !== typeof b) { - return false - } - for (let i = 0; i < props.length; i++) { - const prop = props[i] - - if (typeof a[prop] === 'undefined' || typeof a[prop] !== typeof b[prop] || a[prop] !== b[prop]) { - return false - } - } - return true -} - // From http://detectmobilebrowsers.com/ export function isMobileBrowser () { var check = false;