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

This commit is contained in:
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

View file

@ -147,30 +147,13 @@ export function getNestedReplyText(
export function makeReplyMixIn(ev?: MatrixEvent): RecursivePartial<IContent> { export function makeReplyMixIn(ev?: MatrixEvent): RecursivePartial<IContent> {
if (!ev) return {}; if (!ev) return {};
const mixin: RecursivePartial<IContent> = { return {
'm.relates_to': { 'm.relates_to': {
'm.in_reply_to': { 'm.in_reply_to': {
'event_id': ev.getId(), '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 { export function shouldDisplayReply(event: MatrixEvent): boolean {
@ -210,8 +193,7 @@ export function addReplyToMessageContent(
Object.assign(content, replyContent); Object.assign(content, replyContent);
if (opts.includeLegacyFallback) { if (opts.includeLegacyFallback) {
// Part of Replies fallback support - prepend the text we're sending // Part of Replies fallback support - prepend the text we're sending with the text we're replying to
// with the text we're replying to
const nestedReply = getNestedReplyText(replyToEvent, opts.permalinkCreator); const nestedReply = getNestedReplyText(replyToEvent, opts.permalinkCreator);
if (nestedReply) { if (nestedReply) {
if (content.formatted_body) { if (content.formatted_body) {