Refactor SlashCommands to not use MatrixClientPeg (#10905)
This commit is contained in:
parent
192e6f6c3d
commit
796ed35e75
7 changed files with 244 additions and 170 deletions
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue