Fix explicit replies in threads (#8210)

This commit is contained in:
Michael Telatynski 2022-03-31 18:40:35 +01:00 committed by GitHub
parent f4c25e06cd
commit 17cfd45eb3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 27 deletions

View file

@ -60,14 +60,12 @@ import { KeyBindingAction } from "../../../accessibility/KeyboardShortcuts";
import { PosthogAnalytics } from "../../../PosthogAnalytics";
import { addReplyToMessageContent } from '../../../utils/Reply';
export function attachRelation(
content: IContent,
relation?: IEventRelation,
): void {
// Merges favouring the given relation
export function attachRelation(content: IContent, relation?: IEventRelation): void {
if (relation) {
content['m.relates_to'] = {
...relation, // the composer can have a default
...content['m.relates_to'],
...(content['m.relates_to'] || {}),
...relation,
};
}
}
@ -100,6 +98,7 @@ export function createMessageContent(
content.formatted_body = formattedBody;
}
attachRelation(content, relation);
if (replyToEvent) {
addReplyToMessageContent(content, replyToEvent, {
permalinkCreator,
@ -107,13 +106,6 @@ export function createMessageContent(
});
}
if (relation) {
content['m.relates_to'] = {
...relation,
...content['m.relates_to'],
};
}
return content;
}