From d36637ed13a502696f94003a47f09ea809c636ef Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Sun, 30 Jan 2022 16:50:04 -0500 Subject: [PATCH] Fix a bug causing the /weighted-settings page to fail to detect a change in the source JSON file --- WebHostLib/static/assets/weighted-settings.js | 8 ++++---- WebHostLib/static/styles/weighted-settings.css | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/WebHostLib/static/assets/weighted-settings.js b/WebHostLib/static/assets/weighted-settings.js index b33d7990..8b298795 100644 --- a/WebHostLib/static/assets/weighted-settings.js +++ b/WebHostLib/static/assets/weighted-settings.js @@ -3,12 +3,12 @@ window.addEventListener('load', () => { let settingHash = localStorage.getItem('weighted-settings-hash'); if (!settingHash) { // If no hash data has been set before, set it now - localStorage.setItem('weighted-settings-hash', md5(results)); + localStorage.setItem('weighted-settings-hash', md5(JSON.stringify(results))); localStorage.removeItem('weighted-settings'); - settingHash = md5(results); + settingHash = md5(JSON.stringify(results)); } - if (settingHash !== md5(results)) { + if (settingHash !== md5(JSON.stringify(results))) { const userMessage = document.getElementById('user-message'); userMessage.innerText = "Your settings are out of date! Click here to update them! Be aware this will reset " + "them all to default."; @@ -45,7 +45,7 @@ const resetSettings = () => { const fetchSettingData = () => new Promise((resolve, reject) => { fetch(new Request(`${window.location.origin}/static/generated/weighted-settings.json`)).then((response) => { - try{ resolve(response.json()); } + try{ response.json().then((jsonObj) => resolve(jsonObj)); } catch(error){ reject(error); } }); }); diff --git a/WebHostLib/static/styles/weighted-settings.css b/WebHostLib/static/styles/weighted-settings.css index 6c2a46ff..959a288c 100644 --- a/WebHostLib/static/styles/weighted-settings.css +++ b/WebHostLib/static/styles/weighted-settings.css @@ -213,6 +213,7 @@ html{ #weighted-settings #user-message.visible{ display: block; + cursor: pointer; } #weighted-settings h1{