Attach composer IRelation to slash commands content (#7125)

This commit is contained in:
Germain 2021-11-12 12:43:52 +00:00 committed by GitHub
parent 1e50636520
commit 77c79467c6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -64,7 +64,6 @@ function addReplyToMessageContent(
content: IContent, content: IContent,
replyToEvent: MatrixEvent, replyToEvent: MatrixEvent,
permalinkCreator: RoomPermalinkCreator, permalinkCreator: RoomPermalinkCreator,
relation?: IEventRelation,
): void { ): void {
const replyContent = ReplyChain.makeReplyMixIn(replyToEvent); const replyContent = ReplyChain.makeReplyMixIn(replyToEvent);
Object.assign(content, replyContent); Object.assign(content, replyContent);
@ -78,7 +77,12 @@ function addReplyToMessageContent(
} }
content.body = nestedReply.body + content.body; content.body = nestedReply.body + content.body;
} }
}
export function attachRelation(
content: IContent,
relation?: IEventRelation,
): void {
if (relation) { if (relation) {
content['m.relates_to'] = { content['m.relates_to'] = {
...relation, // the composer can have a default ...relation, // the composer can have a default
@ -417,9 +421,9 @@ export class SendMessageComposer extends React.Component<ISendMessageComposerPro
content, content,
replyToEvent, replyToEvent,
this.props.permalinkCreator, this.props.permalinkCreator,
this.props.relation,
); );
} }
attachRelation(content, this.props.relation);
} else { } else {
this.runSlashCommand(cmd, args); this.runSlashCommand(cmd, args);
shouldSend = false; shouldSend = false;