Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Show updated relation reply from edited message #6809

Merged

Conversation

MadLittleMods
Copy link
Contributor

@MadLittleMods MadLittleMods commented Sep 14, 2021

Show updated relation reply from edited message

When m.relates_to -> m.in_reply_to is provided in m.new_content
for an edited message, use the updated reply.

Before After

ex.

{
  "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"
    }
  }
}

Here's what your changelog entry will look like:

✨ Features

Preview: https://61421f65dde597075b63cc01--matrix-react-sdk.netlify.app
⚠️ Do you trust the author of this PR? Maybe this build will steal your keys or give you malware. Exercise caution. Use test accounts.

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"
    }
  }
}
```
@MadLittleMods MadLittleMods requested a review from a team as a code owner September 14, 2021 21:11
@MadLittleMods MadLittleMods added the T-Enhancement New features, changes in functionality, performance boosts, user-facing improvements label Sep 14, 2021
@MadLittleMods MadLittleMods marked this pull request as draft September 14, 2021 21:11
//
// 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'];
Copy link
Contributor Author

@MadLittleMods MadLittleMods Sep 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works because event.getContent() is smart enough to pull from the latest replacing event (message edit), this._replacingEvent.getContent()["m.new_content"] .

We probably want to also update matrix-js-sdk event.getRelation() to pull from getContent() as well, src/models/event.ts#L1077-L1087. I can create a follow-up PR after this is deemed acceptable 🙇

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updating the js-sdk makes sense, though I'm a bit concerned that the impact could be greater than we anticipate. Until it's reported to cause bugs, we should leave it alone I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know what you mean 🤔

I feel like we may be leaving other clients in the dust if we don't change it though. Someone making a client, bridge, etc just falls into the pitfall of not supporting this use case.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do have a breaking change queued up for the js-sdk's next release, so squeezing it in there would be the safest bet I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I'll skip on adjusting it there because trying to make the change and I run into the rel_type and event_id constraint which isn't present for m.in_repy_to and not sure of the downstream effects.

@MadLittleMods MadLittleMods changed the title Draft: Show updated relation replies from edited message Show updated relation replies from edited message Sep 14, 2021
@MadLittleMods MadLittleMods marked this pull request as ready for review September 14, 2021 21:29
@MadLittleMods MadLittleMods changed the title Show updated relation replies from edited message Show updated relation reply from edited message Sep 15, 2021
Copy link
Member

@turt2live turt2live left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

//
// 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'];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updating the js-sdk makes sense, though I'm a bit concerned that the impact could be greater than we anticipate. Until it's reported to cause bugs, we should leave it alone I think.

@turt2live
Copy link
Member

I think the CI is unhappy because of things outside of your control: merging develop back into this branch should fix it.

@MadLittleMods MadLittleMods merged commit eaab8e1 into develop Sep 15, 2021
@MadLittleMods MadLittleMods deleted the madlittlemods/10391-show-relations-in-new-edit-content branch September 15, 2021 16:49
@MadLittleMods
Copy link
Contributor Author

Thanks for the review @turt2live 🦐 Happy to see this use case supported now!

@MadLittleMods
Copy link
Contributor Author

MadLittleMods commented Sep 15, 2021

@turt2live After pondering about element-hq/element-web#19062, I came up with a previous use case that is now broken.

If you reply to a message originally, then edit the message, the reply disappears. This worked previously because we always looked at the original message. Will need to think of something smarter here. Would you prefer to revert in the mean-time?

@turt2live
Copy link
Member

that does sound not-great :(

reverting is probably the best course of action for now, at least until we can figure out how all these systems are meant to work together (iirc edits and reply fallbacks in particular are largely undefined spec and MSC wise). Are you able to take a look at what might be going sideways?

@MadLittleMods
Copy link
Contributor Author

Are you able to take a look at what might be going sideways?

Yes, I'll write some tests around this too so we don't regress what we know 👍

@MadLittleMods
Copy link
Contributor Author

v2 created at #6817

Palid pushed a commit that referenced this pull request Sep 16, 2021
…nd-quoted-messages

* origin/develop: (80 commits)
  Revert "Show updated relation reply from edited message (#6809)"
  Show updated relation reply from edited message (#6809)
  yarn upgrade
  Pin react too...
  Pin typescript/types version
  Fix checks to show prompt to start new chats
  Fix comment
  lint
  fix tests
  Update comment reflecting tracking scheme via analytics ID
  Remove all room data from tracking
  Fix import, convert event type to constant
  fix lockfile
  Remove replies from hidden events when shown with `messages.ViewSourceEvent` (#6796)
  Convert StatusMessageContextMenu to TS
  Convert GenericTextContextMenu to TS
  Convert GenericElementContextMenu to TS
  Convert MemberStatusMessageAvatar to TS
  More lint
  lint
  ...
@Palid
Copy link
Contributor

Palid commented Sep 17, 2021

@turt2live After pondering about vector-im/element-web#19062, I came up with a previous use case that is now broken.

If you reply to a message originally, then edit the message, the reply disappears. This worked previously because we always looked at the original message. Will need to think of something smarter here. Would you prefer to revert in the mean-time?

Oh, and I wondered why the threaded things are disappearing yesterday and couldn't figure out what's going on! 😄

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
T-Enhancement New features, changes in functionality, performance boosts, user-facing improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants