@@ -20,18 +20,20 @@ import {MatrixClientPeg} from '../../MatrixClientPeg';
2020// XXX: This feels wrong.
2121import { PushProcessor } from "matrix-js-sdk/src/pushprocessor" ;
2222
23- function isMasterRuleEnabled ( ) {
23+ // .m.rule.master being enabled means all events match that push rule
24+ // default action on this rule is dont_notify, but it could be something else
25+ function isPushNotifyDisabled ( ) {
2426 // Return the value of the master push rule as a default
2527 const processor = new PushProcessor ( MatrixClientPeg . get ( ) ) ;
2628 const masterRule = processor . getPushRuleById ( ".m.rule.master" ) ;
2729
2830 if ( ! masterRule ) {
2931 console . warn ( "No master push rule! Notifications are disabled for this user." ) ;
30- return false ;
32+ return true ;
3133 }
3234
33- // Why enabled == false means "enabled" is beyond me.
34- return ! masterRule . enabled ;
35+ // If the rule is enabled then check it does not notify on everything
36+ return masterRule . enabled && ! masterRule . actions . includes ( "notify" ) ;
3537}
3638
3739function getNotifier ( ) {
@@ -45,7 +47,7 @@ export class NotificationsEnabledController extends SettingController {
4547 if ( ! getNotifier ( ) . isPossible ( ) ) return false ;
4648
4749 if ( calculatedValue === null || calculatedAtLevel === "default" ) {
48- return ! isMasterRuleEnabled ( ) ;
50+ return ! isPushNotifyDisabled ( ) ;
4951 }
5052
5153 return calculatedValue ;
@@ -63,7 +65,7 @@ export class NotificationBodyEnabledController extends SettingController {
6365 if ( ! getNotifier ( ) . isPossible ( ) ) return false ;
6466
6567 if ( calculatedValue === null ) {
66- return ! isMasterRuleEnabled ( ) ;
68+ return ! isPushNotifyDisabled ( ) ;
6769 }
6870
6971 return calculatedValue ;
0 commit comments