Use EventType at the state and account data call sites. [skip build]
Checks / checks (push) Successful in 2m4s
Trigger cinny-mobile / dispatch (push) Successful in 1s

This commit is contained in:
2026-11-01 23:50:13 +11:00
parent 634d1e0a0f
commit 48db806dd7
7 changed files with 32 additions and 30 deletions
@@ -3,7 +3,7 @@ import React, { FormEventHandler, useCallback, useMemo, useState } from 'react';
import { useAtomValue } from 'jotai';
import Linkify from 'linkify-react';
import classNames from 'classnames';
import { JoinRule, MatrixError } from 'matrix-js-sdk';
import { EventType, JoinRule, MatrixError } from 'matrix-js-sdk';
import { Icon, Icons } from '../../../components/icons';
import { SequenceCard } from '../../../components/sequence-card';
import { SequenceCardStyle } from '../../room-settings/styles.css';
@@ -82,15 +82,16 @@ export function RoomProfileEdit({
useCallback(
async (roomAvatarMxc?: string | null, roomName?: string, roomTopic?: string) => {
if (roomAvatarMxc !== undefined) {
await mx.sendStateEvent(room.roomId, StateEvent.RoomAvatar as any, {
url: roomAvatarMxc,
// url can be null to clear the avatar, which RoomAvatarEventContent does not allow
await mx.sendStateEvent(room.roomId, EventType.RoomAvatar, {
url: roomAvatarMxc as any,
});
}
if (roomName !== undefined) {
await mx.sendStateEvent(room.roomId, StateEvent.RoomName as any, { name: roomName });
await mx.sendStateEvent(room.roomId, EventType.RoomName, { name: roomName });
}
if (roomTopic !== undefined) {
await mx.sendStateEvent(room.roomId, StateEvent.RoomTopic as any, { topic: roomTopic });
await mx.sendStateEvent(room.roomId, EventType.RoomTopic, { topic: roomTopic });
}
},
[mx, room.roomId],
@@ -13,6 +13,7 @@ import {
} from 'folds';
import FocusTrap from 'focus-trap-react';
import { useAtomValue } from 'jotai';
import { EventType } from 'matrix-js-sdk';
import { Icon, Icons } from '../../components/icons';
import { useAllJoinedRoomsSet, useGetRoom } from '../../hooks/useGetRoom';
import { SpaceProvider } from '../../hooks/useSpace';
@@ -111,8 +112,7 @@ function CreateRoomModal({ state }: CreateRoomModalProps) {
// Add as m.space.child to the space
await mx.sendStateEvent(
parentSpaceId,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
StateEvent.SpaceChild as any,
EventType.SpaceChild,
{ via: spaceViaServers },
newRoomId,
);
+5 -5
View File
@@ -3,7 +3,7 @@ import { Box, Chip, IconButton, Line, Scroll, Spinner, Text, config } from 'fold
import { useVirtualizer } from '@tanstack/react-virtual';
import { useAtom, useAtomValue } from 'jotai';
import { useNavigate } from 'react-router-dom';
import { JoinRule, RestrictedAllowType, Room } from 'matrix-js-sdk';
import { EventType, JoinRule, RestrictedAllowType, Room } from 'matrix-js-sdk';
import { RoomJoinRulesEventContent } from 'matrix-js-sdk/lib/types';
import { IHierarchyRoom } from 'matrix-js-sdk/lib/@types/spaces';
import { produce } from 'immer';
@@ -305,7 +305,7 @@ function SpaceCardLobby() {
if (!reorder.item.parentId) return;
await mx.sendStateEvent(
reorder.item.parentId,
StateEvent.SpaceChild as any,
EventType.SpaceChild,
{ ...reorder.item.content, order: reorder.orderKey },
reorder.item.roomId,
);
@@ -330,7 +330,7 @@ function SpaceCardLobby() {
// remove from current space
if (item.parentId !== containerParentId) {
mx.sendStateEvent(item.parentId, StateEvent.SpaceChild as any, {}, item.roomId);
mx.sendStateEvent(item.parentId, EventType.SpaceChild, {}, item.roomId);
}
if (
@@ -350,7 +350,7 @@ function SpaceCardLobby() {
joinRuleContent.allow?.filter((allowRule) => allowRule.room_id !== item.parentId) ??
[];
allow.push({ type: RestrictedAllowType.RoomMembership, room_id: containerParentId });
mx.sendStateEvent(itemRoom.roomId, StateEvent.RoomJoinRules as any, {
mx.sendStateEvent(itemRoom.roomId, EventType.RoomJoinRules, {
...joinRuleContent,
allow,
});
@@ -392,7 +392,7 @@ function SpaceCardLobby() {
await rateLimitedActions(reorders, async (reorder) => {
await mx.sendStateEvent(
containerParentId,
StateEvent.SpaceChild as any,
EventType.SpaceChild,
{ ...reorder.item.content, order: reorder.orderKey },
reorder.item.roomId,
);
+3 -3
View File
@@ -31,7 +31,7 @@ import React, {
} from 'react';
import FocusTrap from 'focus-trap-react';
import { useHover, useFocusWithin } from 'react-aria';
import { MatrixEvent, Room } from 'matrix-js-sdk';
import { EventType, MatrixEvent, Room } from 'matrix-js-sdk';
import { Relations } from 'matrix-js-sdk/lib/models/relations';
import classNames from 'classnames';
import { RoomPinnedEventsEventContent } from 'matrix-js-sdk/lib/types';
@@ -77,7 +77,7 @@ import { getViaServers } from '../../../plugins/via-servers';
import { useMediaAuthentication } from '../../../hooks/useMediaAuthentication';
import { PluginButtonSlot } from '../../../features/settings/plugins/PluginButtonSlot';
import { useRoomPinnedEvents } from '../../../hooks/useRoomPinnedEvents';
import { MemberPowerTag, StateEvent } from '../../../../types/matrix/room';
import { MemberPowerTag } from '../../../../types/matrix/room';
import { PowerIcon } from '../../../components/power';
import colorMXID from '../../../../util/colorMXID';
import { getPowerTagIconSrc } from '../../../hooks/useMemberPowerTag';
@@ -418,7 +418,7 @@ export const MessagePinItem = as<
if (!isPinned && eventId) {
pinContent.pinned.push(eventId);
}
mx.sendStateEvent(room.roomId, StateEvent.RoomPinnedEvents as any, pinContent);
mx.sendStateEvent(room.roomId, EventType.RoomPinnedEvents, pinContent);
onClose?.();
};