Refactor SlashCommands to not use MatrixClientPeg (#10905)

This commit is contained in:
Michael Telatynski 2023-05-25 16:29:48 +01:00 committed by GitHub
parent 192e6f6c3d
commit 796ed35e75
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 244 additions and 170 deletions

View file

@ -17,6 +17,7 @@ limitations under the License.
import React from "react";
import { logger } from "matrix-js-sdk/src/logger";
import { IContent } from "matrix-js-sdk/src/models/event";
import { MatrixClient } from "matrix-js-sdk/src/matrix";
import EditorModel from "./model";
import { Type } from "./parts";
@ -58,12 +59,13 @@ export function getSlashCommand(model: EditorModel): [Command | undefined, strin
}
export async function runSlashCommand(
matrixClient: MatrixClient,
cmd: Command,
args: string | undefined,
roomId: string,
threadId: string | null,
): Promise<[content: IContent | null, success: boolean]> {
const result = cmd.run(roomId, threadId, args);
const result = cmd.run(matrixClient, roomId, threadId, args);
let messageContent: IContent | null = null;
let error: any = result.error;
if (result.promise) {