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
dont show edit button for messages that are not your own
This commit is contained in:
@ -23,7 +23,7 @@ import dis from '../../../dispatcher';
|
|||||||
import Modal from '../../../Modal';
|
import Modal from '../../../Modal';
|
||||||
import { createMenu } from '../../structures/ContextualMenu';
|
import { createMenu } from '../../structures/ContextualMenu';
|
||||||
import SettingsStore from '../../../settings/SettingsStore';
|
import SettingsStore from '../../../settings/SettingsStore';
|
||||||
import { isContentActionable } from '../../../utils/EventUtils';
|
import { isContentActionable, canEditContent } from '../../../utils/EventUtils';
|
||||||
|
|
||||||
export default class MessageActionBar extends React.PureComponent {
|
export default class MessageActionBar extends React.PureComponent {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
@ -148,12 +148,12 @@ export default class MessageActionBar extends React.PureComponent {
|
|||||||
title={_t("Reply")}
|
title={_t("Reply")}
|
||||||
onClick={this.onReplyClick}
|
onClick={this.onReplyClick}
|
||||||
/>;
|
/>;
|
||||||
if (this.isEditingEnabled()) {
|
}
|
||||||
editButton = <span className="mx_MessageActionBar_maskButton mx_MessageActionBar_editButton"
|
if (this.isEditingEnabled() && canEditContent(this.props.mxEvent)) {
|
||||||
title={_t("Edit")}
|
editButton = <span className="mx_MessageActionBar_maskButton mx_MessageActionBar_editButton"
|
||||||
onClick={this.onEditClick}
|
title={_t("Edit")}
|
||||||
/>;
|
onClick={this.onEditClick}
|
||||||
}
|
/>;
|
||||||
}
|
}
|
||||||
|
|
||||||
return <div className="mx_MessageActionBar">
|
return <div className="mx_MessageActionBar">
|
||||||
|
@ -15,6 +15,7 @@ limitations under the License.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { EventStatus } from 'matrix-js-sdk';
|
import { EventStatus } from 'matrix-js-sdk';
|
||||||
|
import MatrixClientPeg from '../MatrixClientPeg';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether an event should allow actions like reply, reactions, edit, etc.
|
* Returns whether an event should allow actions like reply, reactions, edit, etc.
|
||||||
@ -43,3 +44,8 @@ export function isContentActionable(mxEvent) {
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function canEditContent(mxEvent) {
|
||||||
|
return isContentActionable(mxEvent) &&
|
||||||
|
mxEvent.getSender() === MatrixClientPeg.get().getUserId();
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user