@@ -6,12 +6,13 @@ var Actions = require('../actions/actions');
6
6
var apiRequests = require ( '../utils/api-requests' ) ;
7
7
var SettingsStore = require ( '../stores/settings' ) ;
8
8
9
+ require ( '../stores/sound-notification' ) ;
10
+
9
11
var NotificationsStore = Reflux . createStore ( {
10
12
listenables : Actions ,
11
13
12
14
init : function ( ) {
13
15
this . _notifications = [ ] ;
14
- this . _previousNotifications = [ ] ;
15
16
} ,
16
17
17
18
updateTrayIcon : function ( notifications ) {
@@ -22,35 +23,6 @@ var NotificationsStore = Reflux.createStore({
22
23
}
23
24
} ,
24
25
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
-
54
26
onGetNotifications : function ( ) {
55
27
var self = this ;
56
28
var participating = SettingsStore . getSettings ( ) . participating ;
@@ -63,7 +35,7 @@ var NotificationsStore = Reflux.createStore({
63
35
// Success - Do Something.
64
36
Actions . getNotifications . completed ( response . body ) ;
65
37
self . updateTrayIcon ( response . body ) ;
66
- self . isNewNotification ( response . body ) ;
38
+ Actions . isNewNotification ( response . body ) ;
67
39
} else {
68
40
// Error - Show messages.
69
41
Actions . getNotifications . failed ( err ) ;
0 commit comments