@@ -24,6 +24,9 @@ var NotificationsStore = Reflux.createStore({
24
24
25
25
isNewNotification : function ( response ) {
26
26
var self = this ;
27
+ var playSound = SettingsStore . getSettings ( ) . playSound ;
28
+
29
+ if ( ! playSound ) { return ; }
27
30
28
31
// Check if notification is already in the store.
29
32
var isNew = false ;
@@ -35,8 +38,10 @@ var NotificationsStore = Reflux.createStore({
35
38
36
39
// Play Sound.
37
40
if ( isNew ) {
38
- var audio = new Audio ( 'sounds/digi.wav' ) ;
39
- audio . play ( ) ;
41
+ if ( playSound ) {
42
+ var audio = new Audio ( 'sounds/digi.wav' ) ;
43
+ audio . play ( ) ;
44
+ }
40
45
}
41
46
42
47
// Now Reset the previousNotifications array.
@@ -49,7 +54,6 @@ var NotificationsStore = Reflux.createStore({
49
54
onGetNotifications : function ( ) {
50
55
var self = this ;
51
56
var participating = SettingsStore . getSettings ( ) . participating ;
52
- var playSound = SettingsStore . getSettings ( ) . playSound ;
53
57
54
58
apiRequests
55
59
. getAuth ( 'https://api.github.com/notifications?participating=' +
@@ -59,10 +63,7 @@ var NotificationsStore = Reflux.createStore({
59
63
// Success - Do Something.
60
64
Actions . getNotifications . completed ( response . body ) ;
61
65
self . updateTrayIcon ( response . body ) ;
62
-
63
- if ( playSound ) {
64
- self . isNewNotification ( response . body ) ;
65
- }
66
+ self . isNewNotification ( response . body ) ;
66
67
} else {
67
68
// Error - Show messages.
68
69
Actions . getNotifications . failed ( err ) ;
0 commit comments