@@ -20,11 +20,12 @@ import sdk from 'matrix-react-sdk';
2020import { _t , _tJsx } from 'matrix-react-sdk/lib/languageHandler' ;
2121import MatrixClientPeg from 'matrix-react-sdk/lib/MatrixClientPeg' ;
2222import UserSettingsStore from 'matrix-react-sdk/lib/UserSettingsStore' ;
23+ import SettingsStore , { SettingLevel } from "matrix-react-sdk/lib/settings/SettingsStore" ;
2324import Modal from 'matrix-react-sdk/lib/Modal' ;
2425import {
25- NotificationUtils ,
26- VectorPushRulesDefinitions ,
27- PushRuleVectorState ,
26+ NotificationUtils ,
27+ VectorPushRulesDefinitions ,
28+ PushRuleVectorState ,
2829 ContentRules
2930} from '../../../notifications' ;
3031
@@ -112,12 +113,33 @@ module.exports = React.createClass({
112113 } ,
113114
114115 onEnableDesktopNotificationsChange : function ( event ) {
115- UserSettingsStore . setEnableNotifications ( event . target . checked ) ;
116+ SettingsStore . setValue (
117+ "notificationsEnabled" , null ,
118+ SettingLevel . DEVICE ,
119+ event . target . checked ,
120+ ) . finally ( ( ) => {
121+ this . forceUpdate ( ) ;
122+ } ) ;
116123 } ,
117124
118125 onEnableDesktopNotificationBodyChange : function ( event ) {
119- UserSettingsStore . setEnableNotificationBody ( event . target . checked ) ;
120- this . forceUpdate ( ) ;
126+ SettingsStore . setValue (
127+ "notificationBodyEnabled" , null ,
128+ SettingLevel . DEVICE ,
129+ event . target . checked ,
130+ ) . finally ( ( ) => {
131+ this . forceUpdate ( ) ;
132+ } ) ;
133+ } ,
134+
135+ onEnableAudioNotificationsChange : function ( event ) {
136+ SettingsStore . setValue (
137+ "audioNotificationsEnabled" , null ,
138+ SettingLevel . DEVICE ,
139+ event . target . checked ,
140+ ) . finally ( ( ) => {
141+ this . forceUpdate ( ) ;
142+ } ) ;
121143 } ,
122144
123145 onEnableEmailNotificationsChange : function ( address , event ) {
@@ -433,7 +455,7 @@ module.exports = React.createClass({
433455 needsUpdate . push ( function ( kind , rule ) {
434456 return cli . setPushRuleActions (
435457 'global' , kind , LEGACY_RULES [ rule . rule_id ] , portLegacyActions ( rule . actions )
436- ) . then ( ( ) =>
458+ ) . then ( ( ) =>
437459 cli . deletePushRule ( 'global' , kind , rule . rule_id )
438460 ) . catch ( ( e ) => {
439461 console . warn ( `Error when porting legacy rule: ${ e } ` ) ;
@@ -446,7 +468,7 @@ module.exports = React.createClass({
446468 if ( needsUpdate . length > 0 ) {
447469 // If some of the rules need to be ported then wait for the porting
448470 // to happen and then fetch the rules again.
449- return Promise . all ( needsUpdate ) . then ( ( ) =>
471+ return Promise . all ( needsUpdate ) . then ( ( ) =>
450472 cli . getPushRules ( )
451473 ) ;
452474 } else {
@@ -694,13 +716,13 @@ module.exports = React.createClass({
694716
695717 render : function ( ) {
696718 const self = this ;
697-
719+
698720 let spinner ;
699721 if ( this . state . phase === this . phases . LOADING ) {
700722 const Loader = sdk . getComponent ( "elements.Spinner" ) ;
701723 spinner = < Loader /> ;
702724 }
703-
725+
704726 let masterPushRuleDiv ;
705727 if ( this . state . masterPushRule ) {
706728 masterPushRuleDiv = (
@@ -710,7 +732,7 @@ module.exports = React.createClass({
710732 ref = "enableNotifications"
711733 type = "checkbox"
712734 checked = { ! this . state . masterPushRule . enabled }
713- onChange = { this . onEnableNotificationsChange }
735+ onChange = { this . onEnableNotificationsChange }
714736 />
715737 </ div >
716738 < div className = "mx_UserNotifSettings_labelCell" >
@@ -824,7 +846,7 @@ module.exports = React.createClass({
824846 < input id = "enableDesktopNotifications"
825847 ref = "enableDesktopNotifications"
826848 type = "checkbox"
827- checked = { UserSettingsStore . getEnableNotifications ( ) }
849+ checked = { SettingsStore . getValue ( "notificationsEnabled" ) }
828850 onChange = { this . onEnableDesktopNotificationsChange } />
829851 </ div >
830852 < div className = "mx_UserNotifSettings_labelCell" >
@@ -839,7 +861,7 @@ module.exports = React.createClass({
839861 < input id = "enableDesktopNotificationBody"
840862 ref = "enableDesktopNotificationBody"
841863 type = "checkbox"
842- checked = { UserSettingsStore . getEnableNotificationBody ( ) }
864+ checked = { SettingsStore . getValue ( "notificationBodyEnabled" ) }
843865 onChange = { this . onEnableDesktopNotificationBodyChange } />
844866 </ div >
845867 < div className = "mx_UserNotifSettings_labelCell" >
@@ -854,11 +876,8 @@ module.exports = React.createClass({
854876 < input id = "enableDesktopAudioNotifications"
855877 ref = "enableDesktopAudioNotifications"
856878 type = "checkbox"
857- checked = { UserSettingsStore . getEnableAudioNotifications ( ) }
858- onChange = { ( e ) => {
859- UserSettingsStore . setEnableAudioNotifications ( e . target . checked ) ;
860- this . forceUpdate ( ) ;
861- } } />
879+ checked = { SettingsStore . getValue ( "audioNotificationsEnabled" ) }
880+ onChange = { this . onEnableAudioNotificationsChange } />
862881 </ div >
863882 < div className = "mx_UserNotifSettings_labelCell" >
864883 < label htmlFor = "enableDesktopAudioNotifications" >
0 commit comments