mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-16 21:24:59 +08:00
Merge pull request #3310 from matrix-org/t3chguy/fix_reply_parent_redacted
Fix showing events which were replied to and then redacted
This commit is contained in:
commit
a96df333e9
@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2017 New Vector Ltd
|
Copyright 2017 New Vector Ltd
|
||||||
|
Copyright 2019 Michael Telatynski <7t3chguy@gmail.com>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@ -176,6 +177,9 @@ export default class ReplyThread extends React.Component {
|
|||||||
componentWillMount() {
|
componentWillMount() {
|
||||||
this.unmounted = false;
|
this.unmounted = false;
|
||||||
this.room = this.context.matrixClient.getRoom(this.props.parentEv.getRoomId());
|
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();
|
this.initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,7 +189,20 @@ export default class ReplyThread extends React.Component {
|
|||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
this.unmounted = true;
|
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;
|
||||||
|
|
||||||
|
// 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() {
|
async initialize() {
|
||||||
const {parentEv} = this.props;
|
const {parentEv} = this.props;
|
||||||
@ -298,10 +315,12 @@ export default class ReplyThread extends React.Component {
|
|||||||
|
|
||||||
return <blockquote className="mx_ReplyThread" key={ev.getId()}>
|
return <blockquote className="mx_ReplyThread" key={ev.getId()}>
|
||||||
{ dateSep }
|
{ dateSep }
|
||||||
<EventTile mxEvent={ev}
|
<EventTile
|
||||||
|
mxEvent={ev}
|
||||||
tileShape="reply"
|
tileShape="reply"
|
||||||
onHeightChanged={this.props.onHeightChanged}
|
onHeightChanged={this.props.onHeightChanged}
|
||||||
permalinkCreator={this.props.permalinkCreator}
|
permalinkCreator={this.props.permalinkCreator}
|
||||||
|
isRedacted={ev.isRedacted()}
|
||||||
isTwelveHour={SettingsStore.getValue("showTwelveHourTimestamps")} />
|
isTwelveHour={SettingsStore.getValue("showTwelveHourTimestamps")} />
|
||||||
</blockquote>;
|
</blockquote>;
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user