X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=client%2Fsrc%2Fstore.js;h=b81ec5524639866ad2c1d5c7a9f59732364c6716;hp=52870e0af4cd505204b32eef7f2ffee30ea004ae;hb=db1f1f9adb920605c7a16b060a7737e54636ee08;hpb=e891730f77312340d68bb7ef72a4207541fa3914 diff --git a/client/src/store.js b/client/src/store.js index 52870e0a..b81ec552 100644 --- a/client/src/store.js +++ b/client/src/store.js @@ -53,11 +53,16 @@ export const store = { this.state.user.notify = res.notify; }); // Settings initialized with values from localStorage + const getItemDefaultTrue = (item) => { + const value = localStorage.getItem(item); + if (!value) return true; + return value == "true"; + }; this.state.settings = { bcolor: localStorage.getItem("bcolor") || "lichess", - sound: parseInt(localStorage.getItem("sound")) || 1, - hints: localStorage.getItem("hints") == "true", - highlight: localStorage.getItem("highlight") == "true" + sound: getItemDefaultTrue("sound"), + hints: getItemDefaultTrue("hints"), + highlight: getItemDefaultTrue("highlight") }; const supportedLangs = ["en", "es", "fr"]; const navLanguage = navigator.language.substr(0,2);