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

Commit

Permalink
Fix js-sdk types (#8588)
Browse files Browse the repository at this point in the history
  • Loading branch information
t3chguy authored May 13, 2022
1 parent 1fc8009 commit 6453530
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
18 changes: 12 additions & 6 deletions src/RoomNotifs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ limitations under the License.

import { PushProcessor } from 'matrix-js-sdk/src/pushprocessor';
import { NotificationCountType, Room } from "matrix-js-sdk/src/models/room";
import { ConditionKind, IPushRule, PushRuleActionName, PushRuleKind } from "matrix-js-sdk/src/@types/PushRules";
import {
ConditionKind,
IPushRule,
PushRuleActionName,
PushRuleKind,
TweakName,
} from "matrix-js-sdk/src/@types/PushRules";
import { EventType } from 'matrix-js-sdk/src/@types/event';

import { MatrixClientPeg } from './MatrixClientPeg';
Expand Down Expand Up @@ -144,13 +150,13 @@ function setRoomNotifsStateMuted(roomId: string): Promise<any> {
promises.push(cli.addPushRule('global', PushRuleKind.Override, roomId, {
conditions: [
{
kind: 'event_match',
kind: ConditionKind.EventMatch,
key: 'room_id',
pattern: roomId,
},
],
actions: [
'dont_notify',
PushRuleActionName.DontNotify,
],
}));

Expand All @@ -174,17 +180,17 @@ function setRoomNotifsStateUnmuted(roomId: string, newState: RoomNotifState): Pr
} else if (newState === RoomNotifState.MentionsOnly) {
promises.push(cli.addPushRule('global', PushRuleKind.RoomSpecific, roomId, {
actions: [
'dont_notify',
PushRuleActionName.DontNotify,
],
}));
// https://matrix.org/jira/browse/SPEC-400
promises.push(cli.setPushRuleEnabled('global', PushRuleKind.RoomSpecific, roomId, true));
} else if (newState === RoomNotifState.AllMessagesLoud) {
promises.push(cli.addPushRule('global', PushRuleKind.RoomSpecific, roomId, {
actions: [
'notify',
PushRuleActionName.Notify,
{
set_tweak: 'sound',
set_tweak: TweakName.Sound,
value: 'default',
},
],
Expand Down
2 changes: 1 addition & 1 deletion test/RoomNotifs-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ describe("RoomNotifs test", () => {
rule_id: "!roomId:server",
enabled: true,
default: false,
actions: [{ set_tweak: TweakName.Sound }],
actions: [{ set_tweak: TweakName.Sound, value: "default" }],
});
expect(getRoomNotifsState("!roomId:server")).toBe(RoomNotifState.AllMessagesLoud);
});
Expand Down

0 comments on commit 6453530

Please sign in to comment.