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"
    }
  }
}
```
This commit is contained in:
Eric Eastwood 2021-09-15 11:49:04 -05:00 committed by GitHub
parent 2ffbf3aa72
commit eaab8e1570
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -88,7 +88,10 @@ export default class ReplyThread extends React.Component<IProps, IState> {
// 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'];