@@ -6,12 +6,13 @@ var Actions = require('../actions/actions');
66var apiRequests = require ( '../utils/api-requests' ) ;
77var SettingsStore = require ( '../stores/settings' ) ;
88
9+ require ( '../stores/sound-notification' ) ;
10+
911var NotificationsStore = Reflux . createStore ( {
1012 listenables : Actions ,
1113
1214 init : function ( ) {
1315 this . _notifications = [ ] ;
14- this . _previousNotifications = [ ] ;
1516 } ,
1617
1718 updateTrayIcon : function ( notifications ) {
@@ -22,35 +23,6 @@ var NotificationsStore = Reflux.createStore({
2223 }
2324 } ,
2425
25- isNewNotification : function ( response ) {
26- var self = this ;
27- var playSound = SettingsStore . getSettings ( ) . playSound ;
28-
29- if ( ! playSound ) { return ; }
30-
31- // Check if notification is already in the store.
32- var isNew = false ;
33- _ . map ( response , function ( obj ) {
34- if ( ! _ . contains ( self . _previousNotifications , obj . id ) ) {
35- isNew = true ;
36- }
37- } ) ;
38-
39- // Play Sound.
40- if ( isNew ) {
41- if ( playSound ) {
42- var audio = new Audio ( 'sounds/digi.wav' ) ;
43- audio . play ( ) ;
44- }
45- }
46-
47- // Now Reset the previousNotifications array.
48- self . _previousNotifications = [ ] ;
49- _ . map ( response , function ( obj ) {
50- self . _previousNotifications . push ( obj . id ) ;
51- } ) ;
52- } ,
53-
5426 onGetNotifications : function ( ) {
5527 var self = this ;
5628 var participating = SettingsStore . getSettings ( ) . participating ;
@@ -63,7 +35,7 @@ var NotificationsStore = Reflux.createStore({
6335 // Success - Do Something.
6436 Actions . getNotifications . completed ( response . body ) ;
6537 self . updateTrayIcon ( response . body ) ;
66- self . isNewNotification ( response . body ) ;
38+ Actions . isNewNotification ( response . body ) ;
6739 } else {
6840 // Error - Show messages.
6941 Actions . getNotifications . failed ( err ) ;
0 commit comments