mirror of
https://github.com/SchildiChat/element-web.git
synced 2024-10-01 01:26:12 -04:00
check PL on change as well as on comp load, that way it'll show remove button if PL increases later.
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
d3f9304598
commit
17c4e7a748
@ -40,6 +40,31 @@ module.exports = React.createClass({
|
|||||||
onFinished: React.PropTypes.func,
|
onFinished: React.PropTypes.func,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getInitialState: function() {
|
||||||
|
return {
|
||||||
|
canRedact: false,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
componentWillMount: function() {
|
||||||
|
MatrixClientPeg.get().on('RoomMember.powerLevel', this._checkCanRedact);
|
||||||
|
this._checkCanRedact();
|
||||||
|
},
|
||||||
|
|
||||||
|
componentWillUnmount: function() {
|
||||||
|
const cli = MatrixClientPeg.get();
|
||||||
|
if (cli) {
|
||||||
|
cli.removeListener('RoomMember.powerLevel', this._checkCanRedact);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_checkCanRedact: function() {
|
||||||
|
const cli = MatrixClientPeg.get();
|
||||||
|
const room = cli.getRoom(this.props.mxEvent.getRoomId());
|
||||||
|
const canRedact = room.currentState.maySendRedactionForEvent(this.props.mxEvent, cli.credentials.userId);
|
||||||
|
this.setState({canRedact});
|
||||||
|
},
|
||||||
|
|
||||||
onResendClick: function() {
|
onResendClick: function() {
|
||||||
Resend.resend(this.props.mxEvent);
|
Resend.resend(this.props.mxEvent);
|
||||||
if (this.props.onFinished) this.props.onFinished();
|
if (this.props.onFinished) this.props.onFinished();
|
||||||
@ -136,10 +161,7 @@ module.exports = React.createClass({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const cli = MatrixClientPeg.get();
|
if (this.state.canRedact) {
|
||||||
const room = cli.getRoom(this.props.mxEvent.getRoomId());
|
|
||||||
|
|
||||||
if (room.currentState.maySendRedactionForEvent(this.props.mxEvent, cli.credentials.userId)) {
|
|
||||||
redactButton = (
|
redactButton = (
|
||||||
<div className="mx_MessageContextMenu_field" onClick={this.onRedactClick}>
|
<div className="mx_MessageContextMenu_field" onClick={this.onRedactClick}>
|
||||||
{ _t('Remove') }
|
{ _t('Remove') }
|
||||||
@ -209,7 +231,7 @@ module.exports = React.createClass({
|
|||||||
externalURLButton = (
|
externalURLButton = (
|
||||||
<div className="mx_MessageContextMenu_field">
|
<div className="mx_MessageContextMenu_field">
|
||||||
<a href={ this.props.mxEvent.event.content.external_url }
|
<a href={ this.props.mxEvent.event.content.external_url }
|
||||||
rel="noopener" target="_blank" onClick={ this.closeMenu }>{ _t('Source URL') }</a>
|
rel="noopener" target="_blank" onClick={ this.closeMenu }>{ _t('Source URL') }</a>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user