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:
parent
0842559fb2
commit
ad73b0c16e
52 changed files with 262 additions and 277 deletions
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue