Skip to content

Commit

Permalink
Fix state_events.ts types (#4196)
Browse files Browse the repository at this point in the history
* Fix state_events.ts types

Signed-off-by: Michael Telatynski <[email protected]>

* Iterate

Signed-off-by: Michael Telatynski <[email protected]>

---------

Signed-off-by: Michael Telatynski <[email protected]>
  • Loading branch information
t3chguy authored May 10, 2024
1 parent 2a716bd commit a25cdce
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
8 changes: 0 additions & 8 deletions src/@types/partials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,6 @@ export enum RestrictedAllowType {
RoomMembership = "m.room_membership",
}

export interface IJoinRuleEventContent {
join_rule: JoinRule; // eslint-disable-line camelcase
allow?: {
type: RestrictedAllowType;
room_id: string; // eslint-disable-line camelcase
}[];
}

export enum GuestAccess {
CanJoin = "can_join",
Forbidden = "forbidden",
Expand Down
8 changes: 7 additions & 1 deletion src/@types/state_events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ limitations under the License.
*/

import { RoomType } from "./event";
import { GuestAccess, HistoryVisibility, RestrictedAllowType } from "./partials";
import { GuestAccess, HistoryVisibility, JoinRule, RestrictedAllowType } from "./partials";
import { ImageInfo } from "./media";
import { PolicyRecommendation } from "../models/invites-ignorer";

Expand All @@ -36,12 +36,18 @@ export interface RoomCreateEventContent {
}

export interface RoomJoinRulesEventContent {
join_rule: JoinRule;
allow?: {
room_id: string;
type: RestrictedAllowType;
}[];
}

/**
* @deprecated in favour of RoomJoinRulesEventContent
*/
export type IJoinRuleEventContent = RoomJoinRulesEventContent;

export interface RoomMemberEventContent {
avatar_url?: string;
displayname?: string;
Expand Down
5 changes: 3 additions & 2 deletions src/models/room-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ import { isNumber, removeHiddenChars } from "../utils";
import { EventType, UNSTABLE_MSC2716_MARKER } from "../@types/event";
import { IEvent, MatrixEvent, MatrixEventEvent } from "./event";
import { MatrixClient } from "../client";
import { GuestAccess, HistoryVisibility, IJoinRuleEventContent, JoinRule } from "../@types/partials";
import { GuestAccess, HistoryVisibility, JoinRule } from "../@types/partials";
import { TypedEventEmitter } from "./typed-event-emitter";
import { Beacon, BeaconEvent, BeaconEventHandlerMap, getBeaconInfoIdentifier, BeaconIdentifier } from "./beacon";
import { TypedReEmitter } from "../ReEmitter";
import { M_BEACON, M_BEACON_INFO } from "../@types/beacon";
import { KnownMembership } from "../@types/membership";
import { RoomJoinRulesEventContent } from "../@types/state_events";

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

Expand Down

0 comments on commit a25cdce

Please sign in to comment.