Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 855c69e

Browse files
authored
Iterate type definitions (#7168) (#7178)
1 parent 74fd21c commit 855c69e

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

src/RoomNotifs.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ limitations under the License.
1818
import { MatrixClientPeg } from './MatrixClientPeg';
1919
import { PushProcessor } from 'matrix-js-sdk/src/pushprocessor';
2020
import { 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

2323
export 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
}

src/components/views/dialogs/IncomingSasDialog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const PHASE_VERIFIED = 3;
3939
const PHASE_CANCELLED = 4;
4040

4141
interface IProps extends IDialogProps {
42-
verifier: VerificationBase; // TODO types
42+
verifier: VerificationBase;
4343
}
4444

4545
interface IState {

0 commit comments

Comments
 (0)