Avoid using deprecated exports & methods from matrix-js-sdk (#12359)

This commit is contained in:
Michael Telatynski
2024-03-25 12:21:02 +00:00
committed by GitHub
parent 11912a0da0
commit 4941327c78
24 changed files with 73 additions and 80 deletions
+1 -2
View File
@@ -19,7 +19,6 @@ limitations under the License.
import {
MatrixClient,
MsgType,
IImageInfo,
HTTPError,
IEventRelation,
ISendEventResponse,
@@ -390,7 +389,7 @@ export default class ContentMessages {
url: string,
roomId: string,
threadId: string | null,
info: IImageInfo,
info: ImageInfo,
text: string,
matrixClient: MatrixClient,
): Promise<ISendEventResponse> {
+1 -9
View File
@@ -612,15 +612,7 @@ async function setBotPower(
});
}
}
await client.setPowerLevel(
roomId,
userId,
level,
new MatrixEvent({
type: "m.room.power_levels",
content: powerLevels,
}),
);
await client.setPowerLevel(roomId, userId, level);
return sendResponse(event, {
success: true,
});
@@ -18,7 +18,7 @@ import React, { createRef } from "react";
import {
AuthType,
IAuthData,
IAuthDict,
AuthDict,
IInputs,
InteractiveAuth,
IStageStatus,
@@ -64,7 +64,7 @@ export interface InteractiveAuthProps<T> {
continueText?: string;
continueKind?: ContinueKind;
// callback
makeRequest(auth: IAuthDict | null): Promise<T>;
makeRequest(auth: AuthDict | null): Promise<T>;
// callback called when the auth process has finished,
// successfully or unsuccessfully.
// @param {boolean} status True if the operation requiring
@@ -213,7 +213,7 @@ export default class InteractiveAuthComponent<T> extends React.Component<Interac
);
};
private requestCallback = (auth: IAuthDict | null, background: boolean): Promise<T> => {
private requestCallback = (auth: AuthDict | null, background: boolean): Promise<T> => {
// This wrapper just exists because the js-sdk passes a second
// 'busy' param for backwards compat. This throws the tests off
// so discard it here.
@@ -246,7 +246,7 @@ export default class InteractiveAuthComponent<T> extends React.Component<Interac
this.stageComponent.current?.focus?.();
}
private submitAuthDict = (authData: IAuthDict): void => {
private submitAuthDict = (authData: AuthDict): void => {
this.authLogic.submitAuthDict(authData);
};
@@ -18,7 +18,7 @@ import {
AuthType,
createClient,
IAuthData,
IAuthDict,
AuthDict,
IInputs,
MatrixError,
IRegisterRequestParams,
@@ -478,7 +478,7 @@ export default class Registration extends React.Component<IProps, IState> {
});
};
private makeRegisterRequest = (auth: IAuthDict | null): Promise<RegisterResponse> => {
private makeRegisterRequest = (auth: AuthDict | null): Promise<RegisterResponse> => {
if (!this.state.matrixClient) throw new Error("Matrix client has not yet been loaded");
const registerParams: IRegisterRequestParams = {
@@ -16,7 +16,7 @@ limitations under the License.
import classNames from "classnames";
import { MatrixClient } from "matrix-js-sdk/src/matrix";
import { AuthType, IAuthDict, IInputs, IStageStatus } from "matrix-js-sdk/src/interactive-auth";
import { AuthType, AuthDict, IInputs, IStageStatus } from "matrix-js-sdk/src/interactive-auth";
import { logger } from "matrix-js-sdk/src/logger";
import React, { ChangeEvent, createRef, FormEvent, Fragment } from "react";
@@ -89,7 +89,7 @@ interface IAuthEntryProps {
// Is the auth logic currently waiting for something to happen?
busy?: boolean;
onPhaseChange: (phase: number) => void;
submitAuthDict: (auth: IAuthDict) => void;
submitAuthDict: (auth: AuthDict) => void;
requestEmailToken?: () => Promise<void>;
fail: (error: Error) => void;
clientSecret: string;
@@ -932,7 +932,7 @@ const MuteToggleButton: React.FC<IBaseRoomProps> = ({
return;
}
cli.setPowerLevel(roomId, target, level, powerLevelEvent)
cli.setPowerLevel(roomId, target, level)
.then(
() => {
// NO-OP; rely on the m.room.member event coming down else we could
@@ -1159,13 +1159,8 @@ export const PowerLevelEditor: React.FC<{
async (powerLevel: number) => {
setSelectedPowerLevel(powerLevel);
const applyPowerChange = (
roomId: string,
target: string,
powerLevel: number,
powerLevelEvent: MatrixEvent,
): Promise<unknown> => {
return cli.setPowerLevel(roomId, target, powerLevel, powerLevelEvent).then(
const applyPowerChange = (roomId: string, target: string, powerLevel: number): Promise<unknown> => {
return cli.setPowerLevel(roomId, target, powerLevel).then(
function () {
// NO-OP; rely on the m.room.member event coming down else we could
// get out of sync if we force setState here!
@@ -1213,7 +1208,7 @@ export const PowerLevelEditor: React.FC<{
}
}
await applyPowerChange(roomId, target, powerLevel, powerLevelEvent);
await applyPowerChange(roomId, target, powerLevel);
},
[user.roomId, user.userId, cli, room],
);
@@ -62,7 +62,7 @@ export const AddPrivilegedUsers: React.FC<AddPrivilegedUsersProps> = ({ room, de
}
try {
await client.setPowerLevel(room.roomId, userIds, powerLevel, powerLevelEvent);
await client.setPowerLevel(room.roomId, userIds, powerLevel);
setSelectedUsers([]);
setPowerLevel(defaultUserLevel);
} catch (error) {
@@ -15,7 +15,7 @@ limitations under the License.
*/
import { MatrixClient, MatrixError } from "matrix-js-sdk/src/matrix";
import { IAuthDict, IAuthData } from "matrix-js-sdk/src/interactive-auth";
import { AuthDict, IAuthData } from "matrix-js-sdk/src/interactive-auth";
import { _t } from "../../../../languageHandler";
import Modal from "../../../../Modal";
@@ -25,7 +25,7 @@ import InteractiveAuthDialog from "../../dialogs/InteractiveAuthDialog";
const makeDeleteRequest =
(matrixClient: MatrixClient, deviceIds: string[]) =>
async (auth: IAuthDict | null): Promise<IAuthData> => {
async (auth: AuthDict | null): Promise<IAuthData> => {
return matrixClient.deleteMultipleDevices(deviceIds, auth ?? undefined);
};
+2 -4
View File
@@ -347,15 +347,13 @@ export default async function createRoom(client: MatrixClient, opts: IOpts): Pro
await JitsiCall.create(await room);
// Reset our power level back to admin so that the widget becomes immutable
const plEvent = (await room).currentState.getStateEvents(EventType.RoomPowerLevels, "");
await client.setPowerLevel(roomId, client.getUserId()!, 100, plEvent);
await client.setPowerLevel(roomId, client.getUserId()!, 100);
} else if (opts.roomType === RoomType.UnstableCall) {
// Set up this video room with an Element call
await ElementCall.create(await room);
// Reset our power level back to admin so that the call becomes immutable
const plEvent = (await room).currentState.getStateEvents(EventType.RoomPowerLevels, "");
await client.setPowerLevel(roomId, client.getUserId()!, 100, plEvent);
await client.setPowerLevel(roomId, client.getUserId()!, 100);
}
})
.then(
+1 -3
View File
@@ -74,9 +74,7 @@ export default class JSONExporter extends Exporter {
logger.log("Error fetching file: " + err);
}
}
const jsonEvent: any = mxEv.toJSON();
const clearEvent = mxEv.isEncrypted() ? jsonEvent.decrypted : jsonEvent;
return clearEvent;
return mxEv.getEffectiveEvent();
}
protected async createOutput(events: MatrixEvent[]): Promise<string> {