diff options
author | Renard | 2019-10-04 15:37:19 -0300 |
---|---|---|
committer | Renard | 2019-10-04 15:37:19 -0300 |
commit | 27b8ed315b63269794623fa0d5f034928a430c92 (patch) | |
tree | 9a1b268655e7ecaeb9af6cd08e8f4f0cddcd4cf1 | |
parent | 9395cdf38031bd6fbb4e5b013444f97451b98bcc (diff) | |
download | bai-client-27b8ed315b63269794623fa0d5f034928a430c92.tar.gz bai-client-27b8ed315b63269794623fa0d5f034928a430c92.tar.xz bai-client-27b8ed315b63269794623fa0d5f034928a430c92.zip |
Asignar valores default a opciones faltantes
-rw-r--r-- | src/App.js | 28 |
1 files changed, 17 insertions, 11 deletions
@@ -63,21 +63,27 @@ class App extends Component { let lsSettings = localStorage.getItem("settings"); let settings = JSON.parse(lsSettings); - + const defaultSettings = { + homeSound: "msn", + threadSound: "msn", + nightMode: false, + notifyOnHome: true, + notifyOnThread: true, + autoUpdateThreads: true, + showAvatars: true, + postPassword: this.genPassword(), + embedYoutube: true + }; if (lsSettings === null) { - let defaultSettings = { - homeSound: "msn", - threadSound: "msn", - nightMode: false, - notifyOnHome: true, - notifyOnThread: true, - autoUpdateThreads: true, - showAvatars: true, - postPassword: this.genPassword() - }; localStorage.setItem("settings", JSON.stringify(defaultSettings)); settings = defaultSettings; } else { + Object.keys(defaultSettings).forEach(key => { + if (settings[key] === undefined) { + settings[key] = defaultSettings[key]; + } + }); + localStorage.setItem("settings", JSON.stringify(defaultSettings)); this.setState({ nightMode: settings.nightMode }); } } |