Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Fix replying using chat effect commands (#9101)
Browse files Browse the repository at this point in the history
  • Loading branch information
t3chguy authored Jul 27, 2022
1 parent c0d69e1 commit a2c5a59
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
24 changes: 11 additions & 13 deletions src/SlashCommands.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1305,19 +1305,17 @@ export const Commands = [
description: effect.description(),
args: '<message>',
runFn: function(roomId, args) {
return success((async () => {
if (!args) {
args = effect.fallbackMessage();
MatrixClientPeg.get().sendEmoteMessage(roomId, args);
} else {
const content = {
msgtype: effect.msgType,
body: args,
};
MatrixClientPeg.get().sendMessage(roomId, content);
}
dis.dispatch({ action: `effects.${effect.command}` });
})());
let content: IContent;
if (!args) {
content = ContentHelpers.makeEmoteMessage(effect.fallbackMessage());
} else {
content = {
msgtype: effect.msgType,
body: args,
};
}
dis.dispatch({ action: `effects.${effect.command}` });
return successSync(content);
},
category: CommandCategories.effects,
renderingTypes: [TimelineRenderingType.Room],
Expand Down
2 changes: 1 addition & 1 deletion src/components/views/rooms/EditMessageComposer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ class EditMessageComposer extends React.Component<IEditMessageComposerProps, ISt
return; // errored
}

if (cmd.category === CommandCategories.messages) {
if (cmd.category === CommandCategories.messages || cmd.category === CommandCategories.effects) {
editContent["m.new_content"] = content;
} else {
shouldSend = false;
Expand Down
5 changes: 3 additions & 2 deletions src/components/views/rooms/SendMessageComposer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -358,12 +358,13 @@ export class SendMessageComposer extends React.Component<ISendMessageComposerPro
return; // errored
}

if (cmd.category === CommandCategories.messages) {
if (cmd.category === CommandCategories.messages || cmd.category === CommandCategories.effects) {
attachRelation(content, this.props.relation);
if (replyToEvent) {
addReplyToMessageContent(content, replyToEvent, {
permalinkCreator: this.props.permalinkCreator,
includeLegacyFallback: true,
// Exclude the legacy fallback for custom event types such as those used by /fireworks
includeLegacyFallback: content.msgtype?.startsWith("m.") ?? true,
});
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/editor/commands.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export async function runSlashCommand(
let error = result.error;
if (result.promise) {
try {
if (cmd.category === CommandCategories.messages) {
if (cmd.category === CommandCategories.messages || cmd.category === CommandCategories.effects) {
messageContent = await result.promise;
} else {
await result.promise;
Expand Down

0 comments on commit a2c5a59

Please sign in to comment.