From e4d323d2f29ff61c24fb85784a038791da67a4f6 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Fri, 6 Mar 2020 14:23:20 -0700 Subject: [PATCH] Disable edits on redacted events Fixes https://github.com/vector-im/riot-web/issues/12633 --- src/components/views/messages/MessageActionBar.js | 7 +++++++ src/utils/EventUtils.js | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/views/messages/MessageActionBar.js b/src/components/views/messages/MessageActionBar.js index e07e39b971..fbc864caf2 100644 --- a/src/components/views/messages/MessageActionBar.js +++ b/src/components/views/messages/MessageActionBar.js @@ -121,10 +121,12 @@ export default class MessageActionBar extends React.PureComponent { componentDidMount() { this.props.mxEvent.on("Event.decrypted", this.onDecrypted); + this.props.mxEvent.on("Event.beforeRedaction", this.onBeforeRedaction); } componentWillUnmount() { this.props.mxEvent.removeListener("Event.decrypted", this.onDecrypted); + this.props.mxEvent.removeListener("Event.beforeRedaction", this.onBeforeRedaction); } onDecrypted = () => { @@ -133,6 +135,11 @@ export default class MessageActionBar extends React.PureComponent { this.forceUpdate(); }; + onBeforeRedaction = () => { + // When an event is redacted, we can't edit it so update the available actions. + this.forceUpdate(); + }; + onFocusChange = (focused) => { if (!this.props.onFocusChange) { return; diff --git a/src/utils/EventUtils.js b/src/utils/EventUtils.js index 8acf5ae396..7e33aaed81 100644 --- a/src/utils/EventUtils.js +++ b/src/utils/EventUtils.js @@ -46,7 +46,7 @@ export function isContentActionable(mxEvent) { } export function canEditContent(mxEvent) { - if (mxEvent.status === EventStatus.CANCELLED || mxEvent.getType() !== "m.room.message") { + if (mxEvent.status === EventStatus.CANCELLED || mxEvent.getType() !== "m.room.message" || mxEvent.isRedacted()) { return false; } const content = mxEvent.getOriginalContent();