Skip to content

Commit fdd1565

Browse files
author
Emmanouil Konstantinidis
committed
Handle 'toggle' change
1 parent 5859407 commit fdd1565

File tree

3 files changed

+7
-13
lines changed

3 files changed

+7
-13
lines changed

src/js/actions/actions.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ var Actions = Reflux.createActions({
55
'login': {},
66
'logout': {},
77
'getNotifications': {asyncResult: true},
8-
'getSettings': {},
98
'setSetting': {}
109

1110
});

src/js/components/settings.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
11
var React = require('react');
2-
var Reflux = require('reflux');
32
var Toggle = require('react-toggle');
43

54
var Actions = require('../actions/actions');
65
var SettingsStore = require('../stores/settings');
76

87
var SettingsPage = React.createClass({
9-
mixins: [
10-
Reflux.connect(SettingsStore, 'settings')
11-
],
12-
138
getInitialState: function () {
149
return {
15-
settings: Actions.getSettings()
10+
participating: SettingsStore.getSettings().participating
1611
};
1712
},
1813

19-
toggleParticipating: function () {
20-
Actions.setSetting('participating', !this.state.settings.participating);
14+
toggleParticipating: function (event) {
15+
Actions.setSetting('participating', event.target.checked);
2116
},
2217

2318
render: function () {
@@ -27,7 +22,7 @@ var SettingsPage = React.createClass({
2722
<div className='col-xs-8'>Show only participating</div>
2823
<div className='col-xs-4'>
2924
<Toggle
30-
defaultChecked={this.state.settings.participating}
25+
defaultChecked={this.state.participating}
3126
onChange={this.toggleParticipating} />
3227
</div>
3328
</div>

src/js/stores/settings.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@ var SettingsStore = Reflux.createStore({
99

1010
if (!settings) {
1111
settings = {
12-
'participating': true
12+
'participating': false
1313
};
1414
}
1515

16-
if (settings[0] === "{") {
16+
if (settings[0] === '{') {
1717
settings = JSON.parse(settings);
1818
}
1919

2020
this._settings = settings;
2121
},
2222

23-
onGetSettings: function () {
23+
getSettings: function () {
2424
return this._settings;
2525
},
2626

0 commit comments

Comments
 (0)