@@ -18,7 +18,7 @@ limitations under the License.
1818import { MatrixClientPeg } from './MatrixClientPeg' ;
1919import { PushProcessor } from 'matrix-js-sdk/src/pushprocessor' ;
2020import { NotificationCountType , Room } from "matrix-js-sdk/src/models/room" ;
21- import { IAnnotatedPushRule , PushRuleKind } from "matrix-js-sdk/src/@types/PushRules" ;
21+ import { ConditionKind , IPushRule , PushRuleActionName , PushRuleKind } from "matrix-js-sdk/src/@types/PushRules" ;
2222
2323export enum RoomNotifState {
2424 AllMessagesLoud = 'all_messages_loud' ,
@@ -205,14 +205,12 @@ function setRoomNotifsStateUnmuted(roomId: string, newState: RoomNotifState): Pr
205205 return Promise . all ( promises ) ;
206206}
207207
208- function findOverrideMuteRule ( roomId : string ) : IAnnotatedPushRule {
208+ function findOverrideMuteRule ( roomId : string ) : IPushRule {
209209 const cli = MatrixClientPeg . get ( ) ;
210- if ( ! cli . pushRules ||
211- ! cli . pushRules [ 'global' ] ||
212- ! cli . pushRules [ 'global' ] . override ) {
210+ if ( ! cli ?. pushRules ?. global ?. override ) {
213211 return null ;
214212 }
215- for ( const rule of cli . pushRules [ ' global' ] . override ) {
213+ for ( const rule of cli . pushRules . global . override ) {
216214 if ( isRuleForRoom ( roomId , rule ) ) {
217215 if ( isMuteRule ( rule ) && rule . enabled ) {
218216 return rule ;
@@ -222,14 +220,14 @@ function findOverrideMuteRule(roomId: string): IAnnotatedPushRule {
222220 return null ;
223221}
224222
225- function isRuleForRoom ( roomId : string , rule : IAnnotatedPushRule ) : boolean {
223+ function isRuleForRoom ( roomId : string , rule : IPushRule ) : boolean {
226224 if ( rule . conditions . length !== 1 ) {
227225 return false ;
228226 }
229227 const cond = rule . conditions [ 0 ] ;
230- return ( cond . kind === 'event_match' && cond . key === 'room_id' && cond . pattern === roomId ) ;
228+ return ( cond . kind === ConditionKind . EventMatch && cond . key === 'room_id' && cond . pattern === roomId ) ;
231229}
232230
233- function isMuteRule ( rule : IAnnotatedPushRule ) : boolean {
234- return ( rule . actions . length === 1 && rule . actions [ 0 ] === 'dont_notify' ) ;
231+ function isMuteRule ( rule : IPushRule ) : boolean {
232+ return ( rule . actions . length === 1 && rule . actions [ 0 ] === PushRuleActionName . DontNotify ) ;
235233}
0 commit comments