Fix issue with replying outside a thread to a thread root (#8195)

pull/21833/head
Michael Telatynski 2022-03-30 16:53:15 +01:00 committed by GitHub
parent d09205122d
commit 60ca8996d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 20 deletions

View File

@ -147,30 +147,13 @@ export function getNestedReplyText(
export function makeReplyMixIn(ev?: MatrixEvent): RecursivePartial<IContent> {
if (!ev) return {};
const mixin: RecursivePartial<IContent> = {
return {
'm.relates_to': {
'm.in_reply_to': {
'event_id': ev.getId(),
},
},
};
/**
* If the event replied is part of a thread
* Add the `m.thread` relation so that clients
* that know how to handle that relation will
* be able to render them more accurately
*/
if (ev.isThreadRelation || ev.isThreadRoot) {
mixin['m.relates_to'] = {
...mixin['m.relates_to'],
is_falling_back: false,
rel_type: THREAD_RELATION_TYPE.name,
event_id: ev.threadRootId,
};
}
return mixin;
}
export function shouldDisplayReply(event: MatrixEvent): boolean {
@ -210,8 +193,7 @@ export function addReplyToMessageContent(
Object.assign(content, replyContent);
if (opts.includeLegacyFallback) {
// Part of Replies fallback support - prepend the text we're sending
// with the text we're replying to
// Part of Replies fallback support - prepend the text we're sending with the text we're replying to
const nestedReply = getNestedReplyText(replyToEvent, opts.permalinkCreator);
if (nestedReply) {
if (content.formatted_body) {