Switch to importing most things from the main matrix-js-sdk export (#11406)

* Switch to importing most things from the main matrix-js-sdk export

* fix imports

* Iterate

* Fix tests
This commit is contained in:
Michael Telatynski 2023-08-15 16:00:17 +01:00 committed by GitHub
parent 0842559fb2
commit ad73b0c16e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
52 changed files with 262 additions and 277 deletions

View file

@ -18,12 +18,11 @@ limitations under the License.
*/
import { ReactNode } from "react";
import { createClient, MatrixClient } from "matrix-js-sdk/src/matrix";
import { createClient, MatrixClient, SSOAction } from "matrix-js-sdk/src/matrix";
import { InvalidStoreError } from "matrix-js-sdk/src/errors";
import { decryptAES, encryptAES, IEncryptedPayload } from "matrix-js-sdk/src/crypto/aes";
import { QueryDict } from "matrix-js-sdk/src/utils";
import { logger } from "matrix-js-sdk/src/logger";
import { SSOAction } from "matrix-js-sdk/src/@types/auth";
import { MINIMUM_MATRIX_VERSION } from "matrix-js-sdk/src/version-support";
import { IMatrixClientCreds, MatrixClientPeg } from "./MatrixClientPeg";

View file

@ -15,9 +15,9 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import { createClient, MatrixClient } from "matrix-js-sdk/src/matrix";
import { createClient, MatrixClient, LoginFlow } from "matrix-js-sdk/src/matrix";
import { logger } from "matrix-js-sdk/src/logger";
import { DELEGATED_OIDC_COMPATIBILITY, ILoginFlow, LoginFlow, LoginRequest } from "matrix-js-sdk/src/@types/auth";
import { DELEGATED_OIDC_COMPATIBILITY, ILoginFlow, LoginRequest } from "matrix-js-sdk/src/@types/auth";
import { IMatrixClientCreds } from "./MatrixClientPeg";
import SecurityCustomisations from "./customisations/Security";

View file

@ -26,8 +26,8 @@ import {
EventTimelineSet,
IStartClientOpts,
MatrixClient,
MemoryStore,
} from "matrix-js-sdk/src/matrix";
import { MemoryStore } from "matrix-js-sdk/src/store/memory";
import * as utils from "matrix-js-sdk/src/utils";
import { verificationMethods } from "matrix-js-sdk/src/crypto";
import { SHOW_QR_CODE_METHOD } from "matrix-js-sdk/src/crypto/verification/QRCode";

View file

@ -18,8 +18,7 @@ limitations under the License.
*/
import * as React from "react";
import { User, IContent, Direction } from "matrix-js-sdk/src/matrix";
import * as ContentHelpers from "matrix-js-sdk/src/content-helpers";
import { User, IContent, Direction, ContentHelpers } from "matrix-js-sdk/src/matrix";
import { logger } from "matrix-js-sdk/src/logger";
import { MRoomTopicEventContent } from "matrix-js-sdk/src/@types/topic";

View file

@ -20,11 +20,10 @@ import FileSaver from "file-saver";
import { logger } from "matrix-js-sdk/src/logger";
import { IKeyBackupInfo } from "matrix-js-sdk/src/crypto/keybackup";
import { TrustInfo } from "matrix-js-sdk/src/crypto/backup";
import { CrossSigningKeys, IAuthDict, MatrixError, UIAFlow } from "matrix-js-sdk/src/matrix";
import { CrossSigningKeys, IAuthDict, MatrixError, UIAFlow, UIAResponse } from "matrix-js-sdk/src/matrix";
import { IRecoveryKey } from "matrix-js-sdk/src/crypto/api";
import { CryptoEvent } from "matrix-js-sdk/src/crypto";
import classNames from "classnames";
import { UIAResponse } from "matrix-js-sdk/src/@types/uia";
import { MatrixClientPeg } from "../../../../MatrixClientPeg";
import { _t, _td } from "../../../../languageHandler";

View file

@ -38,9 +38,10 @@ import {
RoomType,
GuestAccess,
HistoryVisibility,
HierarchyRelation,
HierarchyRoom,
} from "matrix-js-sdk/src/matrix";
import { RoomHierarchy } from "matrix-js-sdk/src/room-hierarchy";
import { IHierarchyRelation, IHierarchyRoom } from "matrix-js-sdk/src/@types/spaces";
import classNames from "classnames";
import { sortBy, uniqBy } from "lodash";
import { logger } from "matrix-js-sdk/src/logger";
@ -85,7 +86,7 @@ interface IProps {
}
interface ITileProps {
room: IHierarchyRoom;
room: HierarchyRoom;
suggested?: boolean;
selected?: boolean;
numChildRooms?: number;
@ -429,8 +430,8 @@ export const joinRoom = async (cli: MatrixClient, hierarchy: RoomHierarchy, room
};
interface IHierarchyLevelProps {
root: IHierarchyRoom;
roomSet: Set<IHierarchyRoom>;
root: HierarchyRoom;
roomSet: Set<HierarchyRoom>;
hierarchy: RoomHierarchy;
parents: Set<string>;
selectedMap?: Map<string, Set<string>>;
@ -439,7 +440,7 @@ interface IHierarchyLevelProps {
onToggleClick?(parentId: string, childId: string): void;
}
export const toLocalRoom = (cli: MatrixClient, room: IHierarchyRoom, hierarchy: RoomHierarchy): IHierarchyRoom => {
export const toLocalRoom = (cli: MatrixClient, room: HierarchyRoom, hierarchy: RoomHierarchy): HierarchyRoom => {
const history = cli.getRoomUpgradeHistory(
room.room_id,
true,
@ -497,14 +498,14 @@ export const HierarchyLevel: React.FC<IHierarchyLevelProps> = ({
});
const [subspaces, childRooms] = sortedChildren.reduce(
(result, ev: IHierarchyRelation) => {
(result, ev: HierarchyRelation) => {
const room = hierarchy.roomMap.get(ev.state_key);
if (room && roomSet.has(room)) {
result[room.room_type === RoomType.Space ? 0 : 1].push(toLocalRoom(cli, room, hierarchy));
}
return result;
},
[[] as IHierarchyRoom[], [] as IHierarchyRoom[]],
[[] as HierarchyRoom[], [] as HierarchyRoom[]],
);
const newParents = new Set(parents).add(root.room_id);
@ -564,12 +565,12 @@ export const useRoomHierarchy = (
space: Room,
): {
loading: boolean;
rooms?: IHierarchyRoom[];
rooms?: HierarchyRoom[];
hierarchy?: RoomHierarchy;
error?: Error;
loadMore(pageSize?: number): Promise<void>;
} => {
const [rooms, setRooms] = useState<IHierarchyRoom[]>([]);
const [rooms, setRooms] = useState<HierarchyRoom[]>([]);
const [hierarchy, setHierarchy] = useState<RoomHierarchy>();
const [error, setError] = useState<Error | undefined>();
@ -760,7 +761,7 @@ const SpaceHierarchy: React.FC<IProps> = ({ space, initialText = "", showRoom, a
const { loading, rooms, hierarchy, loadMore, error: hierarchyError } = useRoomHierarchy(space);
const filteredRoomSet = useMemo<Set<IHierarchyRoom>>(() => {
const filteredRoomSet = useMemo<Set<HierarchyRoom>>(() => {
if (!rooms?.length || !hierarchy) return new Set();
const lcQuery = query.toLowerCase().trim();
if (!lcQuery) return new Set(rooms);

View file

@ -17,7 +17,7 @@ limitations under the License.
import React, { ReactNode } from "react";
import classNames from "classnames";
import { logger } from "matrix-js-sdk/src/logger";
import { ISSOFlow, SSOAction } from "matrix-js-sdk/src/@types/auth";
import { SSOFlow, SSOAction } from "matrix-js-sdk/src/matrix";
import { _t, _td, UserFriendlyError } from "../../../languageHandler";
import Login, { ClientLoginFlow, OidcNativeFlow } from "../../../Login";
@ -487,7 +487,7 @@ export default class LoginComponent extends React.PureComponent<IProps, IState>
};
private renderSsoStep = (loginType: "cas" | "sso"): JSX.Element => {
const flow = this.state.flows?.find((flow) => flow.type === "m.login." + loginType) as ISSOFlow;
const flow = this.state.flows?.find((flow) => flow.type === "m.login." + loginType) as SSOFlow;
return (
<SSOButtons

View file

@ -24,11 +24,12 @@ import {
IRegisterRequestParams,
IRequestTokenResponse,
MatrixClient,
SSOFlow,
SSOAction,
} from "matrix-js-sdk/src/matrix";
import React, { Fragment, ReactNode } from "react";
import classNames from "classnames";
import { logger } from "matrix-js-sdk/src/logger";
import { ISSOFlow, SSOAction } from "matrix-js-sdk/src/@types/auth";
import { RegisterResponse } from "matrix-js-sdk/src/@types/registration";
import { _t } from "../../../languageHandler";
@ -121,7 +122,7 @@ interface IState {
differentLoggedInUserId?: string;
// the SSO flow definition, this is fetched from /login as that's the only
// place it is exposed.
ssoFlow?: ISSOFlow;
ssoFlow?: SSOFlow;
}
export default class Registration extends React.Component<IProps, IState> {
@ -219,11 +220,11 @@ export default class Registration extends React.Component<IProps, IState> {
this.loginLogic.setHomeserverUrl(hsUrl);
this.loginLogic.setIdentityServerUrl(isUrl);
let ssoFlow: ISSOFlow | undefined;
let ssoFlow: SSOFlow | undefined;
try {
const loginFlows = await this.loginLogic.getFlows();
if (serverConfig !== this.latestServerConfig) return; // discard, serverConfig changed from under us
ssoFlow = loginFlows.find((f) => f.type === "m.login.sso" || f.type === "m.login.cas") as ISSOFlow;
ssoFlow = loginFlows.find((f) => f.type === "m.login.sso" || f.type === "m.login.cas") as SSOFlow;
} catch (e) {
if (serverConfig !== this.latestServerConfig) return; // discard, serverConfig changed from under us
logger.error("Failed to get login flows to check for SSO support", e);

View file

@ -17,8 +17,7 @@ limitations under the License.
import React, { ChangeEvent, SyntheticEvent } from "react";
import { logger } from "matrix-js-sdk/src/logger";
import { Optional } from "matrix-events-sdk";
import { ISSOFlow, LoginFlow, SSOAction } from "matrix-js-sdk/src/@types/auth";
import { MatrixError } from "matrix-js-sdk/src/matrix";
import { SSOFlow, LoginFlow, SSOAction, MatrixError } from "matrix-js-sdk/src/matrix";
import { _t } from "../../../languageHandler";
import dis from "../../../dispatcher/dispatcher";
@ -257,7 +256,7 @@ export default class SoftLogout extends React.Component<IProps, IState> {
private renderSsoForm(introText: Optional<string>): JSX.Element {
const loginType = this.state.loginView === LoginView.CAS ? "cas" : "sso";
const flow = this.state.flows.find((flow) => flow.type === "m.login." + loginType) as ISSOFlow;
const flow = this.state.flows.find((flow) => flow.type === "m.login." + loginType) as SSOFlow;
return (
<div>

View file

@ -15,8 +15,7 @@ limitations under the License.
*/
import React, { HTMLProps, useContext } from "react";
import { Beacon, BeaconEvent } from "matrix-js-sdk/src/matrix";
import { LocationAssetType } from "matrix-js-sdk/src/@types/location";
import { Beacon, BeaconEvent, LocationAssetType } from "matrix-js-sdk/src/matrix";
import MatrixClientContext from "../../../contexts/MatrixClientContext";
import { useEventEmitterState } from "../../../hooks/useEventEmitter";

View file

@ -16,8 +16,7 @@ limitations under the License.
import React, { ReactNode, useContext } from "react";
import * as maplibregl from "maplibre-gl";
import { Beacon, BeaconEvent } from "matrix-js-sdk/src/matrix";
import { LocationAssetType } from "matrix-js-sdk/src/@types/location";
import { Beacon, BeaconEvent, LocationAssetType } from "matrix-js-sdk/src/matrix";
import MatrixClientContext from "../../../contexts/MatrixClientContext";
import { useEventEmitterState } from "../../../hooks/useEventEmitter";

View file

@ -15,8 +15,7 @@ limitations under the License.
*/
import React, { useContext } from "react";
import { Beacon } from "matrix-js-sdk/src/matrix";
import { LocationAssetType } from "matrix-js-sdk/src/@types/location";
import { Beacon, LocationAssetType } from "matrix-js-sdk/src/matrix";
import MatrixClientContext from "../../../contexts/MatrixClientContext";
import BeaconStatus from "./BeaconStatus";

View file

@ -15,8 +15,7 @@ limitations under the License.
*/
import React, { useContext } from "react";
import { Room, Beacon } from "matrix-js-sdk/src/matrix";
import { LocationAssetType } from "matrix-js-sdk/src/@types/location";
import { Room, Beacon, LocationAssetType } from "matrix-js-sdk/src/matrix";
import { OwnBeaconStore, OwnBeaconStoreEvent } from "../../../stores/OwnBeaconStore";
import { useEventEmitterState } from "../../../hooks/useEventEmitter";

View file

@ -15,7 +15,7 @@ limitations under the License.
*/
import React, { useEffect, useState } from "react";
import { BeaconLocationState } from "matrix-js-sdk/src/content-helpers";
import { ContentHelpers } from "matrix-js-sdk/src/matrix";
import { Icon as ExternalLinkIcon } from "../../../../res/img/external-link.svg";
import { _t } from "../../../languageHandler";
@ -24,7 +24,7 @@ import CopyableText from "../elements/CopyableText";
import TooltipTarget from "../elements/TooltipTarget";
interface Props {
latestLocationState?: BeaconLocationState;
latestLocationState?: ContentHelpers.BeaconLocationState;
}
const ShareLatestLocation: React.FC<Props> = ({ latestLocationState }) => {

View file

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import { BeaconLocationState } from "matrix-js-sdk/src/content-helpers";
import { ContentHelpers } from "matrix-js-sdk/src/matrix";
export enum BeaconDisplayStatus {
Loading = "Loading",
@ -24,7 +24,7 @@ export enum BeaconDisplayStatus {
}
export const getBeaconDisplayStatus = (
isLive: boolean,
latestLocationState?: BeaconLocationState,
latestLocationState?: ContentHelpers.BeaconLocationState,
error?: Error,
waitingToStart?: boolean,
): BeaconDisplayStatus => {

View file

@ -16,9 +16,16 @@ limitations under the License.
import React, { useEffect, useMemo, useState } from "react";
import classnames from "classnames";
import { IContent, MatrixEvent, Room, RoomMember, EventType, MatrixClient } from "matrix-js-sdk/src/matrix";
import {
IContent,
MatrixEvent,
Room,
RoomMember,
EventType,
MatrixClient,
ContentHelpers,
} from "matrix-js-sdk/src/matrix";
import { ILocationContent, LocationAssetType, M_TIMESTAMP } from "matrix-js-sdk/src/@types/location";
import { makeLocationContent } from "matrix-js-sdk/src/content-helpers";
import { M_BEACON } from "matrix-js-sdk/src/@types/beacon";
import { _t } from "../../../languageHandler";
@ -176,7 +183,7 @@ const transformEvent = (event: MatrixEvent): { type: string; content: IContent }
type,
content: {
...content,
...makeLocationContent(
...ContentHelpers.makeLocationContent(
undefined, // text
geoUri,
timestamp || Date.now(),

View file

@ -17,9 +17,8 @@ limitations under the License.
*/
import React from "react";
import { MatrixClient } from "matrix-js-sdk/src/matrix";
import { MatrixClient, UIAResponse } from "matrix-js-sdk/src/matrix";
import { AuthType } from "matrix-js-sdk/src/interactive-auth";
import { UIAResponse } from "matrix-js-sdk/src/@types/uia";
import { _t } from "../../../languageHandler";
import AccessibleButton from "../elements/AccessibleButton";

View file

@ -15,7 +15,7 @@ limitations under the License.
*/
import React, { ChangeEvent, createRef, SyntheticEvent } from "react";
import { AutoDiscovery } from "matrix-js-sdk/src/autodiscovery";
import { AutoDiscovery } from "matrix-js-sdk/src/matrix";
import { logger } from "matrix-js-sdk/src/logger";
import AutoDiscoveryUtils from "../../../utils/AutoDiscoveryUtils";

View file

@ -16,9 +16,8 @@ limitations under the License.
*/
import React from "react";
import { CrossSigningKeys, AuthDict, MatrixError, UIAFlow } from "matrix-js-sdk/src/matrix";
import { CrossSigningKeys, AuthDict, MatrixError, UIAFlow, UIAResponse } from "matrix-js-sdk/src/matrix";
import { logger } from "matrix-js-sdk/src/logger";
import { UIAResponse } from "matrix-js-sdk/src/@types/uia";
import { MatrixClientPeg } from "../../../../MatrixClientPeg";
import { _t } from "../../../../languageHandler";

View file

@ -17,8 +17,14 @@ limitations under the License.
import { WebSearch as WebSearchEvent } from "@matrix-org/analytics-events/types/typescript/WebSearch";
import classNames from "classnames";
import { capitalize, sum } from "lodash";
import { IHierarchyRoom } from "matrix-js-sdk/src/@types/spaces";
import { IPublicRoomsChunkRoom, MatrixClient, RoomMember, RoomType, Room } from "matrix-js-sdk/src/matrix";
import {
IPublicRoomsChunkRoom,
MatrixClient,
RoomMember,
RoomType,
Room,
HierarchyRoom,
} from "matrix-js-sdk/src/matrix";
import { normalize } from "matrix-js-sdk/src/utils";
import React, { ChangeEvent, RefObject, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
import sanitizeHtml from "sanitize-html";
@ -825,7 +831,7 @@ const SpotlightDialog: React.FC<IProps> = ({ initialText = "", initialFilter = n
</h4>
<div>
{spaceResults.slice(0, SECTION_LIMIT).map(
(room: IHierarchyRoom): JSX.Element => (
(room: HierarchyRoom): JSX.Element => (
<Option
id={`mx_SpotlightDialog_button_result_${room.room_id}`}
key={room.room_id}

View file

@ -17,15 +17,9 @@ limitations under the License.
import React from "react";
import { chunk } from "lodash";
import classNames from "classnames";
import { MatrixClient } from "matrix-js-sdk/src/matrix";
import { MatrixClient, IdentityProviderBrand, SSOFlow, SSOAction } from "matrix-js-sdk/src/matrix";
import { Signup } from "@matrix-org/analytics-events/types/typescript/Signup";
import {
IdentityProviderBrand,
IIdentityProvider,
ISSOFlow,
DELEGATED_OIDC_COMPATIBILITY,
SSOAction,
} from "matrix-js-sdk/src/@types/auth";
import { IIdentityProvider, DELEGATED_OIDC_COMPATIBILITY } from "matrix-js-sdk/src/@types/auth";
import PlatformPeg from "../../../PlatformPeg";
import AccessibleButton from "./AccessibleButton";
@ -147,7 +141,7 @@ const SSOButton: React.FC<ISSOButtonProps> = ({
interface IProps {
matrixClient: MatrixClient;
flow: ISSOFlow;
flow: SSOFlow;
loginType: "sso" | "cas";
fragmentAfterLogin?: string;
primary?: boolean;

View file

@ -14,10 +14,16 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import { MatrixClient, IContent, IEventRelation, MatrixError, THREAD_RELATION_TYPE } from "matrix-js-sdk/src/matrix";
import { makeLocationContent, makeBeaconInfoContent } from "matrix-js-sdk/src/content-helpers";
import {
MatrixClient,
IContent,
IEventRelation,
MatrixError,
THREAD_RELATION_TYPE,
ContentHelpers,
LocationAssetType,
} from "matrix-js-sdk/src/matrix";
import { logger } from "matrix-js-sdk/src/logger";
import { LocationAssetType } from "matrix-js-sdk/src/@types/location";
import { _t } from "../../../languageHandler";
import Modal from "../../../Modal";
@ -109,7 +115,7 @@ export const shareLiveLocation =
try {
await OwnBeaconStore.instance.createLiveBeacon(
roomId,
makeBeaconInfoContent(
ContentHelpers.makeBeaconInfoContent(
timeout ?? DEFAULT_LIVE_DURATION,
true /* isLive */,
description,
@ -134,7 +140,13 @@ export const shareLocation =
try {
const threadId = (relation?.rel_type === THREAD_RELATION_TYPE.name && relation?.event_id) || null;
const assetType = shareType === LocationShareType.Pin ? LocationAssetType.Pin : LocationAssetType.Self;
const content = makeLocationContent(undefined, uri, timestamp, undefined, assetType) as IContent;
const content = ContentHelpers.makeLocationContent(
undefined,
uri,
timestamp,
undefined,
assetType,
) as IContent;
await doMaybeLocalRoomAction(
roomId,
(actualRoomId: string) => client.sendMessage(actualRoomId, threadId, content),

View file

@ -23,8 +23,8 @@ import {
MatrixClient,
RelationType,
IRedactOpts,
ContentHelpers,
} from "matrix-js-sdk/src/matrix";
import { BeaconLocationState } from "matrix-js-sdk/src/content-helpers";
import { randomString } from "matrix-js-sdk/src/randomstring";
import { M_BEACON } from "matrix-js-sdk/src/@types/beacon";
import classNames from "classnames";
@ -51,7 +51,7 @@ const useBeaconState = (
): {
beacon?: Beacon;
description?: string;
latestLocationState?: BeaconLocationState;
latestLocationState?: ContentHelpers.BeaconLocationState;
isLive?: boolean;
waitingToStart?: boolean;
} => {

View file

@ -15,7 +15,7 @@ limitations under the License.
*/
import React, { ComponentProps, lazy, Suspense } from "react";
import { ISendEventResponse } from "matrix-js-sdk/src/@types/requests";
import { ISendEventResponse } from "matrix-js-sdk/src/matrix";
// we need to import the types for TS, but do not import the sendMessage
// function to avoid importing from "@matrix-org/matrix-wysiwyg"

View file

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import { ISendEventResponse } from "matrix-js-sdk/src/@types/requests";
import { ISendEventResponse } from "matrix-js-sdk/src/matrix";
import { useCallback, useState } from "react";
import { useMatrixClientContext } from "../../../../../contexts/MatrixClientContext";

View file

@ -26,8 +26,14 @@ import React, {
ReactNode,
} from "react";
import classNames from "classnames";
import { RoomType, HistoryVisibility, Preset, Visibility, MatrixClient } from "matrix-js-sdk/src/matrix";
import { ICreateRoomOpts } from "matrix-js-sdk/src/@types/requests";
import {
RoomType,
HistoryVisibility,
Preset,
Visibility,
MatrixClient,
ICreateRoomOpts,
} from "matrix-js-sdk/src/matrix";
import { logger } from "matrix-js-sdk/src/logger";
import { _t } from "../../../languageHandler";

View file

@ -15,7 +15,7 @@ limitations under the License.
*/
import { JoinedRoom as JoinedRoomEvent } from "@matrix-org/analytics-events/types/typescript/JoinedRoom";
import { IJoinRoomOpts } from "matrix-js-sdk/src/@types/requests";
import { IJoinRoomOpts } from "matrix-js-sdk/src/matrix";
import { ActionPayload } from "../payloads";
import { Action } from "../actions";

View file

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import { KnockRoomOpts } from "matrix-js-sdk/src/@types/requests";
import { KnockRoomOpts } from "matrix-js-sdk/src/matrix";
import { Action } from "../actions";
import { ActionPayload } from "../payloads";

View file

@ -15,19 +15,18 @@ limitations under the License.
*/
import { useEffect, useState } from "react";
import { EventType, MatrixEvent, Room, RoomStateEvent } from "matrix-js-sdk/src/matrix";
import { parseTopicContent, TopicState } from "matrix-js-sdk/src/content-helpers";
import { EventType, MatrixEvent, Room, RoomStateEvent, ContentHelpers } from "matrix-js-sdk/src/matrix";
import { MRoomTopicEventContent } from "matrix-js-sdk/src/@types/topic";
import { Optional } from "matrix-events-sdk";
import { useTypedEventEmitter } from "../useEventEmitter";
export const getTopic = (room?: Room): Optional<TopicState> => {
export const getTopic = (room?: Room): Optional<ContentHelpers.TopicState> => {
const content = room?.currentState?.getStateEvents(EventType.RoomTopic, "")?.getContent<MRoomTopicEventContent>();
return !!content ? parseTopicContent(content) : null;
return !!content ? ContentHelpers.parseTopicContent(content) : null;
};
export function useTopic(room?: Room): Optional<TopicState> {
export function useTopic(room?: Room): Optional<ContentHelpers.TopicState> {
const [topic, setTopic] = useState(getTopic(room));
useTypedEventEmitter(room?.currentState, RoomStateEvent.Events, (ev: MatrixEvent) => {
if (ev.getType() !== EventType.RoomTopic) return;

View file

@ -14,8 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import { RoomType, IProtocol, IPublicRoomsChunkRoom } from "matrix-js-sdk/src/matrix";
import { IRoomDirectoryOptions } from "matrix-js-sdk/src/@types/requests";
import { RoomType, IProtocol, IPublicRoomsChunkRoom, IRoomDirectoryOptions } from "matrix-js-sdk/src/matrix";
import { useCallback, useEffect, useState } from "react";
import { IPublicRoomDirectoryConfig } from "../components/views/directory/NetworkDropdown";

View file

@ -15,15 +15,14 @@ limitations under the License.
*/
import { useCallback, useEffect, useMemo, useState } from "react";
import { Room, RoomType } from "matrix-js-sdk/src/matrix";
import { IHierarchyRoom } from "matrix-js-sdk/src/@types/spaces";
import { Room, RoomType, HierarchyRoom } from "matrix-js-sdk/src/matrix";
import { RoomHierarchy } from "matrix-js-sdk/src/room-hierarchy";
import { normalize } from "matrix-js-sdk/src/utils";
import { MatrixClientPeg } from "../MatrixClientPeg";
export const useSpaceResults = (space: Room | undefined, query: string): [IHierarchyRoom[], boolean] => {
const [rooms, setRooms] = useState<IHierarchyRoom[]>([]);
export const useSpaceResults = (space: Room | undefined, query: string): [HierarchyRoom[], boolean] => {
const [rooms, setRooms] = useState<HierarchyRoom[]>([]);
const [hierarchy, setHierarchy] = useState<RoomHierarchy>();
const resetHierarchy = useCallback(() => {

View file

@ -24,8 +24,8 @@ import {
RoomMember,
RoomState,
RoomStateEvent,
ContentHelpers,
} from "matrix-js-sdk/src/matrix";
import { BeaconInfoState, makeBeaconContent, makeBeaconInfoContent } from "matrix-js-sdk/src/content-helpers";
import { MBeaconInfoEventContent, M_BEACON } from "matrix-js-sdk/src/@types/beacon";
import { logger } from "matrix-js-sdk/src/logger";
@ -549,13 +549,16 @@ export class OwnBeaconStore extends AsyncStoreWithClient<OwnBeaconStoreState> {
* Records error in beaconUpdateErrors
* rethrows
*/
private updateBeaconEvent = async (beacon: Beacon, update: Partial<BeaconInfoState>): Promise<void> => {
private updateBeaconEvent = async (
beacon: Beacon,
update: Partial<ContentHelpers.BeaconInfoState>,
): Promise<void> => {
const { description, timeout, timestamp, live, assetType } = {
...beacon.beaconInfo,
...update,
};
const updateContent = makeBeaconInfoContent(timeout, live, description, assetType, timestamp);
const updateContent = ContentHelpers.makeBeaconInfoContent(timeout, live, description, assetType, timestamp);
try {
await this.matrixClient!.unstable_setLiveBeacon(beacon.roomId, updateContent);
@ -593,7 +596,7 @@ export class OwnBeaconStore extends AsyncStoreWithClient<OwnBeaconStoreState> {
* Sends m.location event to referencing given beacon
*/
private sendLocationToBeacon = async (beacon: Beacon, { geoUri, timestamp }: TimedGeoUri): Promise<void> => {
const content = makeBeaconContent(geoUri, timestamp, beacon.beaconInfoId);
const content = ContentHelpers.makeBeaconContent(geoUri, timestamp, beacon.beaconInfoId);
try {
await this.matrixClient!.sendEvent(beacon.roomId, M_BEACON.name, content);
this.incrementBeaconLocationPublishErrorCount(beacon.identifier, false);

View file

@ -24,9 +24,9 @@ import {
RoomStateEvent,
MatrixEvent,
ClientEvent,
ISendEventResponse,
} from "matrix-js-sdk/src/matrix";
import { logger } from "matrix-js-sdk/src/logger";
import { ISendEventResponse } from "matrix-js-sdk/src/@types/requests";
import { AsyncStoreWithClient } from "../AsyncStoreWithClient";
import defaultDispatcher from "../../dispatcher/dispatcher";

View file

@ -14,8 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import { Room } from "matrix-js-sdk/src/matrix";
import { IHierarchyRoom } from "matrix-js-sdk/src/@types/spaces";
import { Room, HierarchyRoom } from "matrix-js-sdk/src/matrix";
import { _t } from "../../languageHandler";
@ -50,7 +49,7 @@ export const getMetaSpaceName = (spaceKey: MetaSpace, allRoomsInHome = false): s
export type SpaceKey = MetaSpace | Room["roomId"];
export interface ISuggestedRoom extends IHierarchyRoom {
export interface ISuggestedRoom extends HierarchyRoom {
viaServers: string[];
}

View file

@ -15,8 +15,13 @@ limitations under the License.
*/
import React, { ReactNode } from "react";
import { AutoDiscovery, ClientConfig, OidcClientConfig } from "matrix-js-sdk/src/autodiscovery";
import { M_AUTHENTICATION, IClientWellKnown } from "matrix-js-sdk/src/matrix";
import {
AutoDiscovery,
ClientConfig,
OidcClientConfig,
M_AUTHENTICATION,
IClientWellKnown,
} from "matrix-js-sdk/src/matrix";
import { logger } from "matrix-js-sdk/src/logger";
import { _t, UserFriendlyError } from "../languageHandler";

View file

@ -15,7 +15,7 @@ limitations under the License.
*/
import { AuthDict } from "matrix-js-sdk/src/interactive-auth";
import { UIAResponse } from "matrix-js-sdk/src/@types/uia";
import { UIAResponse } from "matrix-js-sdk/src/matrix";
import Modal from "../Modal";
import InteractiveAuthDialog, { InteractiveAuthDialogProps } from "../components/views/dialogs/InteractiveAuthDialog";

View file

@ -14,8 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import { OidcClientConfig } from "matrix-js-sdk/src/autodiscovery";
import { IDelegatedAuthConfig } from "matrix-js-sdk/src/matrix";
import { OidcClientConfig, IDelegatedAuthConfig } from "matrix-js-sdk/src/matrix";
import { ValidatedIssuerConfig } from "matrix-js-sdk/src/oidc/validate";
export type ValidatedDelegatedAuthConfig = IDelegatedAuthConfig & ValidatedIssuerConfig;

View file

@ -14,8 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import { BeaconInfoState } from "matrix-js-sdk/src/content-helpers";
import { Beacon } from "matrix-js-sdk/src/matrix";
import { Beacon, ContentHelpers } from "matrix-js-sdk/src/matrix";
/**
* Get ms until expiry
@ -27,7 +26,7 @@ import { Beacon } from "matrix-js-sdk/src/matrix";
export const msUntilExpiry = (startTimestamp: number, durationMs: number): number =>
Math.max(0, startTimestamp + durationMs - Date.now());
export const getBeaconMsUntilExpiry = (beaconInfo: BeaconInfoState): number =>
export const getBeaconMsUntilExpiry = (beaconInfo: ContentHelpers.BeaconInfoState): number =>
msUntilExpiry(beaconInfo.timestamp || 0, beaconInfo.timeout);
export const getBeaconExpiryTimestamp = (beacon: Beacon): number =>

View file

@ -16,7 +16,7 @@ limitations under the License.
import { completeAuthorizationCodeGrant, generateOidcAuthorizationUrl } from "matrix-js-sdk/src/oidc/authorize";
import { QueryDict } from "matrix-js-sdk/src/utils";
import { OidcClientConfig } from "matrix-js-sdk/src/autodiscovery";
import { OidcClientConfig } from "matrix-js-sdk/src/matrix";
import { randomString } from "matrix-js-sdk/src/randomstring";
/**