Remove spurious type casts and avoid deprecated symbols (#12513)

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski 2024-05-13 11:48:07 +01:00 committed by GitHub
parent 113299db43
commit ed7a21a63c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 9 additions and 23 deletions

View file

@ -17,7 +17,7 @@ import { Icon as ExternalLinkIcon } from "@vector-im/compound-design-tokens/icon
import { Button, IconButton, Tooltip } from "@vector-im/compound-web"; import { Button, IconButton, Tooltip } from "@vector-im/compound-web";
import React, { useCallback } from "react"; import React, { useCallback } from "react";
import { logger } from "matrix-js-sdk/src/logger"; import { logger } from "matrix-js-sdk/src/logger";
import { EventType, IJoinRuleEventContent, JoinRule, Room } from "matrix-js-sdk/src/matrix"; import { EventType, JoinRule, Room } from "matrix-js-sdk/src/matrix";
import Modal from "../../../../Modal"; import Modal from "../../../../Modal";
import ShareDialog from "../../dialogs/ShareDialog"; import ShareDialog from "../../dialogs/ShareDialog";
@ -118,7 +118,7 @@ export const JoinRuleDialog: React.FC<{
EventType.RoomJoinRules, EventType.RoomJoinRules,
{ {
join_rule: newRule, join_rule: newRule,
} as IJoinRuleEventContent, },
"", "",
); );
// Show the dialog for a bit to give the user feedback // Show the dialog for a bit to give the user feedback

View file

@ -15,16 +15,8 @@ limitations under the License.
*/ */
import React, { ChangeEvent, ReactNode } from "react"; import React, { ChangeEvent, ReactNode } from "react";
import { import { Room, RoomMember, EventType, RoomType, JoinRule, MatrixError } from "matrix-js-sdk/src/matrix";
Room, import { KnownMembership, RoomJoinRulesEventContent } from "matrix-js-sdk/src/types";
RoomMember,
EventType,
RoomType,
IJoinRuleEventContent,
JoinRule,
MatrixError,
} from "matrix-js-sdk/src/matrix";
import { KnownMembership } from "matrix-js-sdk/src/types";
import classNames from "classnames"; import classNames from "classnames";
import { RoomPreviewOpts, RoomViewLifecycle } from "@matrix-org/react-sdk-module-api/lib/lifecycles/RoomViewLifecycle"; import { RoomPreviewOpts, RoomViewLifecycle } from "@matrix-org/react-sdk-module-api/lib/lifecycles/RoomViewLifecycle";
@ -257,7 +249,7 @@ export default class RoomPreviewBar extends React.Component<IProps, IState> {
return ( return (
this.props.room?.currentState this.props.room?.currentState
.getStateEvents(EventType.RoomJoinRules, "") .getStateEvents(EventType.RoomJoinRules, "")
?.getContent<IJoinRuleEventContent>().join_rule ?? null ?.getContent<RoomJoinRulesEventContent>().join_rule ?? null
); );
} }

View file

@ -15,14 +15,8 @@ limitations under the License.
*/ */
import React, { ReactNode, useEffect, useState } from "react"; import React, { ReactNode, useEffect, useState } from "react";
import { import { JoinRule, RestrictedAllowType, Room, EventType, Visibility } from "matrix-js-sdk/src/matrix";
IJoinRuleEventContent, import { RoomJoinRulesEventContent } from "matrix-js-sdk/src/types";
JoinRule,
RestrictedAllowType,
Room,
EventType,
Visibility,
} from "matrix-js-sdk/src/matrix";
import StyledRadioGroup, { IDefinition } from "../elements/StyledRadioGroup"; import StyledRadioGroup, { IDefinition } from "../elements/StyledRadioGroup";
import { _t } from "../../../languageHandler"; import { _t } from "../../../languageHandler";
@ -72,7 +66,7 @@ const JoinRuleSettings: React.FC<JoinRuleSettingsProps> = ({
const disabled = !room.currentState.mayClientSendStateEvent(EventType.RoomJoinRules, cli); const disabled = !room.currentState.mayClientSendStateEvent(EventType.RoomJoinRules, cli);
const [content, setContent] = useLocalEcho<IJoinRuleEventContent | undefined, IJoinRuleEventContent>( const [content, setContent] = useLocalEcho<RoomJoinRulesEventContent | undefined, RoomJoinRulesEventContent>(
() => room.currentState.getStateEvents(EventType.RoomJoinRules, "")?.getContent(), () => room.currentState.getStateEvents(EventType.RoomJoinRules, "")?.getContent(),
(content) => cli.sendStateEvent(room.roomId, EventType.RoomJoinRules, content, ""), (content) => cli.sendStateEvent(room.roomId, EventType.RoomJoinRules, content, ""),
onError, onError,
@ -391,7 +385,7 @@ const JoinRuleSettings: React.FC<JoinRuleSettingsProps> = ({
if (beforeJoinRule === joinRule && !restrictedAllowRoomIds) return; if (beforeJoinRule === joinRule && !restrictedAllowRoomIds) return;
if (beforeChange && !(await beforeChange(joinRule))) return; if (beforeChange && !(await beforeChange(joinRule))) return;
const newContent: IJoinRuleEventContent = { const newContent: RoomJoinRulesEventContent = {
join_rule: joinRule, join_rule: joinRule,
}; };