More safely parse JSON from localStorage

This commit is contained in:
Noah 2023-09-07 21:03:15 -07:00
parent a2cb32cce2
commit dbfd45794a

View File

@ -40,7 +40,12 @@ class UserSettings {
case Boolean:
this[key] = localStorage[key] === "true";
case Object:
try {
this[key] = JSON.parse(localStorage[key]);
} catch(e) {
console.error(`LocalStorage: parsing key ${key}: ${e}`);
delete(this[key]);
}
}
}
}