File tree Expand file tree Collapse file tree 2 files changed +17
-13
lines changed
Expand file tree Collapse file tree 2 files changed +17
-13
lines changed Original file line number Diff line number Diff line change @@ -12,9 +12,7 @@ var SettingsPage = React.createClass({
1212
1313 getInitialState : function ( ) {
1414 return {
15- settings : {
16- participating : false
17- }
15+ settings : Actions . getSettings ( )
1816 } ;
1917 } ,
2018
@@ -26,7 +24,7 @@ var SettingsPage = React.createClass({
2624 return (
2725 < div className = "container-fluid main-container settings" >
2826 < div className = 'row' >
29- < div className = 'col-xs-8' > Setting Title </ div >
27+ < div className = 'col-xs-8' > Show only participating </ div >
3028 < div className = 'col-xs-4' >
3129 < Toggle
3230 defaultChecked = { this . state . settings . participating }
Original file line number Diff line number Diff line change @@ -5,13 +5,19 @@ var SettingsStore = Reflux.createStore({
55 listenables : Actions ,
66
77 init : function ( ) {
8- var settings = window . localStorage . getItem ( 'settings' ) || {
9- participating : false
10- } ;
11- var participatingSetting = settings . participating ;
12- this . _settings = {
13- participating : participatingSetting
14- } ;
8+ var settings = window . localStorage . getItem ( 'settings' ) ;
9+
10+ if ( ! settings ) {
11+ settings = {
12+ 'participating' : true
13+ } ;
14+ }
15+
16+ if ( settings [ 0 ] === "{" ) {
17+ settings = JSON . parse ( settings ) ;
18+ }
19+
20+ this . _settings = settings ;
1521 } ,
1622
1723 onGetSettings : function ( ) {
@@ -20,8 +26,8 @@ var SettingsStore = Reflux.createStore({
2026
2127 onSetSetting : function ( setting , value ) {
2228 console . log ( 'Setting: ' + setting + ' to: ' + value ) ;
23- window . localStorage . setItem ( 'settings' , this . _settings ) ;
24- this . _settings . participating = value ;
29+ this . _settings [ setting ] = value ;
30+ window . localStorage . setItem ( 'settings' , JSON . stringify ( this . _settings ) ) ;
2531 this . trigger ( this . _settings ) ;
2632 }
2733
You can’t perform that action at this time.
0 commit comments