You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-07-28 15:22:05 +03:00
Disable edits on redacted events
Fixes https://github.com/vector-im/riot-web/issues/12633
This commit is contained in:
@ -121,10 +121,12 @@ export default class MessageActionBar extends React.PureComponent {
|
|||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.props.mxEvent.on("Event.decrypted", this.onDecrypted);
|
this.props.mxEvent.on("Event.decrypted", this.onDecrypted);
|
||||||
|
this.props.mxEvent.on("Event.beforeRedaction", this.onBeforeRedaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
this.props.mxEvent.removeListener("Event.decrypted", this.onDecrypted);
|
this.props.mxEvent.removeListener("Event.decrypted", this.onDecrypted);
|
||||||
|
this.props.mxEvent.removeListener("Event.beforeRedaction", this.onBeforeRedaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
onDecrypted = () => {
|
onDecrypted = () => {
|
||||||
@ -133,6 +135,11 @@ export default class MessageActionBar extends React.PureComponent {
|
|||||||
this.forceUpdate();
|
this.forceUpdate();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
onBeforeRedaction = () => {
|
||||||
|
// When an event is redacted, we can't edit it so update the available actions.
|
||||||
|
this.forceUpdate();
|
||||||
|
};
|
||||||
|
|
||||||
onFocusChange = (focused) => {
|
onFocusChange = (focused) => {
|
||||||
if (!this.props.onFocusChange) {
|
if (!this.props.onFocusChange) {
|
||||||
return;
|
return;
|
||||||
|
@ -46,7 +46,7 @@ export function isContentActionable(mxEvent) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function canEditContent(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;
|
return false;
|
||||||
}
|
}
|
||||||
const content = mxEvent.getOriginalContent();
|
const content = mxEvent.getOriginalContent();
|
||||||
|
Reference in New Issue
Block a user