Skip to content

Commit 35af639

Browse files
author
Emmanouil Konstantinidis
committed
Setting for 'play sound' & play sound only if on
1 parent 3447a31 commit 35af639

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

src/js/components/settings.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ var SettingsPage = React.createClass({
1313
};
1414
},
1515

16-
toggleParticipating: function (event) {
17-
Actions.setSetting('participating', event.target.checked);
16+
toggleSetting: function (key, event) {
17+
Actions.setSetting(key, event.target.checked);
1818
},
1919

2020
appQuit: function () {
@@ -29,7 +29,15 @@ var SettingsPage = React.createClass({
2929
<div className='col-xs-4'>
3030
<Toggle
3131
defaultChecked={this.state.participating}
32-
onChange={this.toggleParticipating} />
32+
onChange={this.toggleSetting.bind(this, 'participating')} />
33+
</div>
34+
</div>
35+
<div className='row'>
36+
<div className='col-xs-8'>Play sound</div>
37+
<div className='col-xs-4'>
38+
<Toggle
39+
defaultChecked={this.state.participating}
40+
onChange={this.toggleSetting.bind(this, 'play-sound')} />
3341
</div>
3442
</div>
3543
<div className='row'>

src/js/stores/notifications.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ var NotificationsStore = Reflux.createStore({
4949
onGetNotifications: function () {
5050
var self = this;
5151
var participating = SettingsStore.getSettings().participating;
52+
var playSound = SettingsStore.getSettings().playSound;
5253

5354
apiRequests
5455
.getAuth('https://api.github.com/notifications?participating=' +
@@ -58,7 +59,10 @@ var NotificationsStore = Reflux.createStore({
5859
// Success - Do Something.
5960
Actions.getNotifications.completed(response.body);
6061
self.updateTrayIcon(response.body);
61-
self.isNewNotification(response.body);
62+
63+
if (playSound) {
64+
self.isNewNotification(response.body);
65+
}
6266
} else {
6367
// Error - Show messages.
6468
Actions.getNotifications.failed(err);

src/js/stores/settings.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ var SettingsStore = Reflux.createStore({
99

1010
if (!settings) {
1111
settings = {
12-
'participating': false
12+
'participating': false,
13+
'playSound': true
1314
};
1415
}
1516

0 commit comments

Comments
 (0)