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

@ -341,7 +341,13 @@ class EditMessageComposer extends React.Component<IEditMessageComposerProps, ISt
const [cmd, args, commandText] = getSlashCommand(this.model);
if (cmd) {
const threadId = editedEvent?.getThread()?.id || null;
const [content, commandSuccessful] = await runSlashCommand(cmd, args, roomId, threadId);
const [content, commandSuccessful] = await runSlashCommand(
MatrixClientPeg.get(),
cmd,
args,
roomId,
threadId,
);
if (!commandSuccessful) {
return; // errored
}

View file

@ -474,6 +474,7 @@ export class SendMessageComposer extends React.Component<ISendMessageComposerPro
let commandSuccessful: boolean;
[content, commandSuccessful] = await runSlashCommand(
MatrixClientPeg.get(),
cmd,
args,
this.props.room.roomId,

View file

@ -85,7 +85,7 @@ export async function sendMessage(
if (cmd) {
const threadId = relation?.rel_type === THREAD_RELATION_TYPE.name ? relation?.event_id : null;
let commandSuccessful: boolean;
[content, commandSuccessful] = await runSlashCommand(cmd, args, roomId, threadId ?? null);
[content, commandSuccessful] = await runSlashCommand(mxClient, cmd, args, roomId, threadId ?? null);
if (!commandSuccessful) {
return; // errored