@@ -40,6 +40,31 @@ module.exports = React.createClass({
4040 onFinished : React . PropTypes . func ,
4141 } ,
4242
43+ getInitialState : function ( ) {
44+ return {
45+ canRedact : false ,
46+ } ;
47+ } ,
48+
49+ componentWillMount : function ( ) {
50+ MatrixClientPeg . get ( ) . on ( 'RoomMember.powerLevel' , this . _checkCanRedact ) ;
51+ this . _checkCanRedact ( ) ;
52+ } ,
53+
54+ componentWillUnmount : function ( ) {
55+ const cli = MatrixClientPeg . get ( ) ;
56+ if ( cli ) {
57+ cli . removeListener ( 'RoomMember.powerLevel' , this . _checkCanRedact ) ;
58+ }
59+ } ,
60+
61+ _checkCanRedact : function ( ) {
62+ const cli = MatrixClientPeg . get ( ) ;
63+ const room = cli . getRoom ( this . props . mxEvent . getRoomId ( ) ) ;
64+ const canRedact = room . currentState . maySendRedactionForEvent ( this . props . mxEvent , cli . credentials . userId ) ;
65+ this . setState ( { canRedact} ) ;
66+ } ,
67+
4368 onResendClick : function ( ) {
4469 Resend . resend ( this . props . mxEvent ) ;
4570 if ( this . props . onFinished ) this . props . onFinished ( ) ;
@@ -136,7 +161,7 @@ module.exports = React.createClass({
136161 ) ;
137162 }
138163
139- if ( ! eventStatus && ! this . props . mxEvent . isRedacted ( ) ) { // sent and not redacted
164+ if ( this . state . canRedact ) {
140165 redactButton = (
141166 < div className = "mx_MessageContextMenu_field" onClick = { this . onRedactClick } >
142167 { _t ( 'Remove' ) }
@@ -206,7 +231,7 @@ module.exports = React.createClass({
206231 externalURLButton = (
207232 < div className = "mx_MessageContextMenu_field" >
208233 < a href = { this . props . mxEvent . event . content . external_url }
209- rel = "noopener" target = "_blank" onClick = { this . closeMenu } > { _t ( 'Source URL' ) } </ a >
234+ rel = "noopener" target = "_blank" onClick = { this . closeMenu } > { _t ( 'Source URL' ) } </ a >
210235 </ div >
211236 ) ;
212237 }
0 commit comments