From 7fc39e132947b162e3f803ba46cc15cbf3f1d4db Mon Sep 17 00:00:00 2001 From: Renard Date: Sun, 22 Sep 2019 19:27:31 -0300 Subject: nightMode setting --- src/App.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/App.js b/src/App.js index 9ea8330..864eaa2 100644 --- a/src/App.js +++ b/src/App.js @@ -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() { -- cgit v1.2.1-18-gbd029