diff options
author | Renard | 2019-09-22 19:27:31 -0300 |
---|---|---|
committer | Renard | 2019-09-22 19:27:31 -0300 |
commit | 7fc39e132947b162e3f803ba46cc15cbf3f1d4db (patch) | |
tree | f75bd735aa9827cecb898f169a80254ae8756cfd | |
parent | ebb25e4d544449c06cfd08064a28df77b923fc19 (diff) | |
download | bai-client-7fc39e132947b162e3f803ba46cc15cbf3f1d4db.tar.gz bai-client-7fc39e132947b162e3f803ba46cc15cbf3f1d4db.tar.xz bai-client-7fc39e132947b162e3f803ba46cc15cbf3f1d4db.zip |
nightMode setting
-rw-r--r-- | src/App.js | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -23,7 +23,7 @@ class App extends Component { this.state = { boardList: [], isLoaded: false, - nightMode: true + nightMode: false }; this.toggleTheme = this.toggleTheme.bind(this); } @@ -36,6 +36,13 @@ class App extends Component { .then(resource => { this.setState({ boardList: resource["boards"], isLoaded: true }); }); + + let _nightMode = localStorage.getItem("nightMode"); + if (_nightMode === null) { + localStorage.setItem("nightMode", false); + } else { + this.setState({ nightMode: JSON.parse(_nightMode) }); + } } componentDidUpdate() { @@ -47,7 +54,9 @@ class App extends Component { } toggleTheme() { - this.setState({ nightMode: !this.state.nightMode }); + this.setState({ nightMode: !this.state.nightMode }, () => { + localStorage.setItem("nightMode", this.state.nightMode); + }); } render() { |