File tree Expand file tree Collapse file tree 3 files changed +29
-8
lines changed
Expand file tree Collapse file tree 3 files changed +29
-8
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,8 @@ var SettingsPage = React.createClass({
1111 var settings = SettingsStore . getSettings ( ) ;
1212 return {
1313 participating : settings . participating ,
14- playSound : settings . playSound
14+ playSound : settings . playSound ,
15+ showNotifications : settings . showNotifications
1516 } ;
1617 } ,
1718
@@ -42,6 +43,14 @@ var SettingsPage = React.createClass({
4243 onChange = { this . toggleSetting . bind ( this , 'playSound' ) } />
4344 </ div >
4445 </ div >
46+ < div className = 'row' >
47+ < div className = 'col-xs-8' > Show notifications</ div >
48+ < div className = 'col-xs-4' >
49+ < Toggle
50+ defaultChecked = { this . state . showNotifications }
51+ onChange = { this . toggleSetting . bind ( this , 'showNotifications' ) } />
52+ </ div >
53+ </ div >
4554 < div className = 'row' >
4655 < button
4756 className = 'btn btn-block btn-danger btn-close'
Original file line number Diff line number Diff line change @@ -25,9 +25,9 @@ var NotificationsStore = Reflux.createStore({
2525 isNewNotification : function ( response ) {
2626 var self = this ;
2727 var playSound = SettingsStore . getSettings ( ) . playSound ;
28- var showNotification = SettingsStore . getSettings ( ) . showNotification ;
28+ var showNotifications = SettingsStore . getSettings ( ) . showNotifications ;
2929
30- if ( ! playSound && ! showNotification ) { return ; }
30+ if ( ! playSound && ! showNotifications ) { return ; }
3131
3232 // Check if notification is already in the store.
3333 var countNew = 0 ;
@@ -43,10 +43,10 @@ var NotificationsStore = Reflux.createStore({
4343 var audio = new Audio ( 'sounds/digi.wav' ) ;
4444 audio . play ( ) ;
4545 }
46- if ( showNotification ) {
47- var body = ( countNew = 1 ?
46+ if ( showNotifications ) {
47+ var body = ( countNew == 1 ?
4848 'You\'ve got a new notification' :
49- 'You\'ve got ' + countNew + 'notifications' ) ;
49+ 'You\'ve got ' + countNew + ' notifications. ' ) ;
5050 var nativeNotification = new Notification ( 'Gitify' , {
5151 body : body
5252 } ) ;
Original file line number Diff line number Diff line change @@ -9,16 +9,28 @@ var SettingsStore = Reflux.createStore({
99
1010 if ( ! settings ) {
1111 settings = {
12- 'participating' : false ,
13- 'playSound' : true
12+ participating : false ,
13+ playSound : true ,
14+ showNotifications : true
1415 } ;
1516 }
1617
1718 if ( settings [ 0 ] === '{' ) {
1819 settings = JSON . parse ( settings ) ;
1920 }
2021
22+ if ( ! settings . participating ) {
23+ settings . participating = false ;
24+ }
25+ if ( ! settings . playSound ) {
26+ settings . playSound = true ;
27+ }
28+ if ( ! settings . showNotifications ) {
29+ settings . showNotifications = true ;
30+ }
31+
2132 this . _settings = settings ;
33+ window . localStorage . setItem ( 'settings' , JSON . stringify ( this . _settings ) ) ;
2234 } ,
2335
2436 getSettings : function ( ) {
You can’t perform that action at this time.
0 commit comments