Fix a bug causing the /weighted-settings page to fail to detect a change in the source JSON file

This commit is contained in:
Chris Wilson 2022-01-30 16:50:04 -05:00
parent dd5e5dcda7
commit d36637ed13
2 changed files with 5 additions and 4 deletions

View File

@ -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); }
});
});

View File

@ -213,6 +213,7 @@ html{
#weighted-settings #user-message.visible{
display: block;
cursor: pointer;
}
#weighted-settings h1{