From eaab8e15701da82fbc93f54ab34bacb2e3ab1361 Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Wed, 15 Sep 2021 11:49:04 -0500 Subject: [PATCH] Show updated relation reply from edited message (#6809) Part of https://github.com/vector-im/element-web/issues/10391#issuecomment-906131724 When `m.relates_to` -> `m.in_reply_to` is provided in `m.new_content` for an edited message, use the updated reply. ex. ```json { "type": "m.room.message", "content": { "body": " * foo bar", "msgtype": "m.text", "m.new_content": { "body": "foo bar", "msgtype": "m.text", "m.relates_to": { "m.in_reply_to": { "event_id": "$qkjmFBTEc0VvfVyzq1CJuh1QZi_xDIgNEFjZ4Pq34og" } } }, "m.relates_to": { "rel_type": "m.replace", "event_id": "$lX9MRe9ZTFOOvnU8PRVbvr1wqGtYvNQ1rSot-iUTN5k" } } } ``` --- src/components/views/elements/ReplyThread.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/views/elements/ReplyThread.tsx b/src/components/views/elements/ReplyThread.tsx index d061d52f46..d7e34dc784 100644 --- a/src/components/views/elements/ReplyThread.tsx +++ b/src/components/views/elements/ReplyThread.tsx @@ -88,7 +88,10 @@ export default class ReplyThread extends React.Component { // could be used here for replies as well... However, the helper // currently assumes the relation has a `rel_type`, which older replies // do not, so this block is left as-is for now. - const mRelatesTo = ev.getWireContent()['m.relates_to']; + // + // We're using ev.getContent() over ev.getWireContent() to make sure + // we grab the latest edit with potentially new relations. + const mRelatesTo = ev.getContent()['m.relates_to']; if (mRelatesTo && mRelatesTo['m.in_reply_to']) { const mInReplyTo = mRelatesTo['m.in_reply_to']; if (mInReplyTo && mInReplyTo['event_id']) return mInReplyTo['event_id'];