From 6589e5dab906c8ad3591c3c51892be45c8113ec7 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 13 Aug 2019 18:13:47 +0100 Subject: [PATCH 1/3] Fix showing events which were replied to and then redacted --- src/components/views/elements/ReplyThread.js | 27 ++++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/components/views/elements/ReplyThread.js b/src/components/views/elements/ReplyThread.js index ab7b1abb1c..d8955a9f28 100644 --- a/src/components/views/elements/ReplyThread.js +++ b/src/components/views/elements/ReplyThread.js @@ -176,6 +176,9 @@ export default class ReplyThread extends React.Component { componentWillMount() { this.unmounted = false; this.room = this.context.matrixClient.getRoom(this.props.parentEv.getRoomId()); + this.room.on("Room.redaction", this.onRoomRedaction); + // same event handler as Room.redaction as for both we just do forceUpdate + this.room.on("Room.redactionCancelled", this.onRoomRedaction); this.initialize(); } @@ -185,8 +188,20 @@ export default class ReplyThread extends React.Component { componentWillUnmount() { this.unmounted = true; + if (this.room) { + this.room.removeListener("Room.redaction", this.onRoomRedaction); + this.room.removeListener("Room.redactionCancelled", this.onRoomRedaction); + } } + onRoomRedaction = (ev, room) => { + if (this.unmounted) return; + + // we could skip an update if the event isn't in our timeline, + // but that's probably an early optimisation. + this.forceUpdate(); + }; + async initialize() { const {parentEv} = this.props; // at time of making this component we checked that props.parentEv has a parentEventId @@ -298,11 +313,13 @@ export default class ReplyThread extends React.Component { return
{ dateSep } -; }); From a44d61fb75a9b6b4068ec415f1e09bc2d2def18e Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 13 Aug 2019 18:17:42 +0100 Subject: [PATCH 2/3] add copyright Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/views/elements/ReplyThread.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/views/elements/ReplyThread.js b/src/components/views/elements/ReplyThread.js index d8955a9f28..126b4ef017 100644 --- a/src/components/views/elements/ReplyThread.js +++ b/src/components/views/elements/ReplyThread.js @@ -1,5 +1,6 @@ /* Copyright 2017 New Vector Ltd +Copyright 2019 Michael Telatynski <7t3chguy@gmail.com> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. From 6f529852cdb43b8853cd2e1115bbde0635be30ac Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 14 Aug 2019 23:27:04 +0100 Subject: [PATCH 3/3] Skip forceUpdate in ReplyThread if the redacted event is not relevant Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/views/elements/ReplyThread.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/components/views/elements/ReplyThread.js b/src/components/views/elements/ReplyThread.js index 126b4ef017..08630a16a5 100644 --- a/src/components/views/elements/ReplyThread.js +++ b/src/components/views/elements/ReplyThread.js @@ -198,9 +198,10 @@ export default class ReplyThread extends React.Component { onRoomRedaction = (ev, room) => { if (this.unmounted) return; - // we could skip an update if the event isn't in our timeline, - // but that's probably an early optimisation. - this.forceUpdate(); + // If one of the events we are rendering gets redacted, force a re-render + if (this.state.events.some(event => event.getId() === ev.getId())) { + this.forceUpdate(); + } }; async initialize() {+