Skip to content

Commit a25cdce

Browse files
authored
Fix state_events.ts types (#4196)
* Fix state_events.ts types Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --------- Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
1 parent 2a716bd commit a25cdce

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

src/@types/partials.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,6 @@ export enum RestrictedAllowType {
4545
RoomMembership = "m.room_membership",
4646
}
4747

48-
export interface IJoinRuleEventContent {
49-
join_rule: JoinRule; // eslint-disable-line camelcase
50-
allow?: {
51-
type: RestrictedAllowType;
52-
room_id: string; // eslint-disable-line camelcase
53-
}[];
54-
}
55-
5648
export enum GuestAccess {
5749
CanJoin = "can_join",
5850
Forbidden = "forbidden",

src/@types/state_events.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ limitations under the License.
1515
*/
1616

1717
import { RoomType } from "./event";
18-
import { GuestAccess, HistoryVisibility, RestrictedAllowType } from "./partials";
18+
import { GuestAccess, HistoryVisibility, JoinRule, RestrictedAllowType } from "./partials";
1919
import { ImageInfo } from "./media";
2020
import { PolicyRecommendation } from "../models/invites-ignorer";
2121

@@ -36,12 +36,18 @@ export interface RoomCreateEventContent {
3636
}
3737

3838
export interface RoomJoinRulesEventContent {
39+
join_rule: JoinRule;
3940
allow?: {
4041
room_id: string;
4142
type: RestrictedAllowType;
4243
}[];
4344
}
4445

46+
/**
47+
* @deprecated in favour of RoomJoinRulesEventContent
48+
*/
49+
export type IJoinRuleEventContent = RoomJoinRulesEventContent;
50+
4551
export interface RoomMemberEventContent {
4652
avatar_url?: string;
4753
displayname?: string;

src/models/room-state.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@ import { isNumber, removeHiddenChars } from "../utils";
2020
import { EventType, UNSTABLE_MSC2716_MARKER } from "../@types/event";
2121
import { IEvent, MatrixEvent, MatrixEventEvent } from "./event";
2222
import { MatrixClient } from "../client";
23-
import { GuestAccess, HistoryVisibility, IJoinRuleEventContent, JoinRule } from "../@types/partials";
23+
import { GuestAccess, HistoryVisibility, JoinRule } from "../@types/partials";
2424
import { TypedEventEmitter } from "./typed-event-emitter";
2525
import { Beacon, BeaconEvent, BeaconEventHandlerMap, getBeaconInfoIdentifier, BeaconIdentifier } from "./beacon";
2626
import { TypedReEmitter } from "../ReEmitter";
2727
import { M_BEACON, M_BEACON_INFO } from "../@types/beacon";
2828
import { KnownMembership } from "../@types/membership";
29+
import { RoomJoinRulesEventContent } from "../@types/state_events";
2930

3031
export interface IMarkerFoundOptions {
3132
/** Whether the timeline was empty before the marker event arrived in the
@@ -962,7 +963,7 @@ export class RoomState extends TypedEventEmitter<EmittedEvents, EventHandlerMap>
962963
*/
963964
public getJoinRule(): JoinRule {
964965
const joinRuleEvent = this.getStateEvents(EventType.RoomJoinRules, "");
965-
const joinRuleContent: Partial<IJoinRuleEventContent> = joinRuleEvent?.getContent() ?? {};
966+
const joinRuleContent: Partial<RoomJoinRulesEventContent> = joinRuleEvent?.getContent() ?? {};
966967
return joinRuleContent["join_rule"] || JoinRule.Invite;
967968
}
968969

0 commit comments

Comments
 (0)