From fddc20dd8961b762afc8faaa7edb3c7cfe3e4f75 Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Tue, 14 Sep 2021 12:28:28 -0500 Subject: [PATCH] Remove replies from hidden events when shown with `messages.ViewSourceEvent` (#6796) As discovered in https://github.com/vector-im/element-web/issues/10391#is Previously, if you turned on the `showHiddenEventsInTimeline` labs flag, edit (`m.replace`) events that also have a `m.in_reply_to` field, will show the reply in the timeline. ex. ``` { "type": "m.room.message", "content": { "body": " * foo", "msgtype": "m.text", "m.new_content": { "body": "foo", "msgtype": "m.text" }, "m.relates_to": { "rel_type": "m.replace", "event_id": "$yvuev9bF2nLRf8fscG55njpVjY3FHJzWgZ4BKI9_0eg", "m.in_reply_to": { "event_id": "$qkjmFBTEc0VvfVyzq1CJuh1QZi_xDIgNEFjZ4Pq34og" } } } } ``` --- src/components/views/rooms/EventTile.tsx | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/components/views/rooms/EventTile.tsx b/src/components/views/rooms/EventTile.tsx index 315241c074..cd4d7e39f2 100644 --- a/src/components/views/rooms/EventTile.tsx +++ b/src/components/views/rooms/EventTile.tsx @@ -1192,14 +1192,19 @@ export default class EventTile extends React.Component { } default: { - const thread = ReplyThread.makeThread( - this.props.mxEvent, - this.props.onHeightChanged, - this.props.permalinkCreator, - this.replyThread, - this.props.layout, - this.props.alwaysShowTimestamps || this.state.hover, - ); + let thread; + // When the "showHiddenEventsInTimeline" lab is enabled, + // avoid showing replies for hidden events (events without tiles) + if (haveTileForEvent(this.props.mxEvent)) { + thread = ReplyThread.makeThread( + this.props.mxEvent, + this.props.onHeightChanged, + this.props.permalinkCreator, + this.replyThread, + this.props.layout, + this.props.alwaysShowTimestamps || this.state.hover, + ); + } const isOwnEvent = this.props.mxEvent?.sender?.userId === MatrixClientPeg.get().getUserId();