aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Renard 2019-10-04 15:37:19 -0300
committerLibravatar Renard 2019-10-04 15:37:19 -0300
commit27b8ed315b63269794623fa0d5f034928a430c92 (patch)
tree9a1b268655e7ecaeb9af6cd08e8f4f0cddcd4cf1
parent9395cdf38031bd6fbb4e5b013444f97451b98bcc (diff)
downloadbai-client-27b8ed315b63269794623fa0d5f034928a430c92.tar.gz
bai-client-27b8ed315b63269794623fa0d5f034928a430c92.tar.xz
bai-client-27b8ed315b63269794623fa0d5f034928a430c92.zip
Asignar valores default a opciones faltantes
-rw-r--r--src/App.js28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/App.js b/src/App.js
index 43bb29e..04a2726 100644
--- a/src/App.js
+++ b/src/App.js
@@ -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 });
}
}