Don't show the unpin button if the user can't unpin the message.

Signed-off-by: Travis Ralston <travpc@gmail.com>
pull/5142/head
Travis Ralston 2017-09-29 10:53:44 -06:00
parent 9b11f576fe
commit 59a253af37
2 changed files with 12 additions and 3 deletions

View File

@ -55,6 +55,9 @@ const PinnedEventTile = React.createClass({
} else if (this.props.onUnpinned) this.props.onUnpinned();
}
},
_canUnpin: function() {
return this.props.mxRoom.currentState.mayClientSendStateEvent('m.room.pinned_events', MatrixClientPeg.get());
},
render: function() {
const MessageEvent = sdk.getComponent("views.messages.MessageEvent");
const MemberAvatar = sdk.getComponent("views.avatars.MemberAvatar");
@ -62,14 +65,19 @@ const PinnedEventTile = React.createClass({
const sender = this.props.mxRoom.getMember(this.props.mxEvent.getSender());
const avatarSize = 40;
let unpinButton = null;
if (this._canUnpin()) {
unpinButton = <img src="img/cancel-red.svg" className="mx_PinnedEventTile_unpinButton" width="8" height="8"
onClick={this.onUnpinClicked} alt={_t('Unpin Message')} title={_t('Unpin Message')} />;
}
return (
<div className="mx_PinnedEventTile">
<div className="mx_PinnedEventTile_actions">
<AccessibleButton className="mx_PinnedEventTile_gotoButton mx_textButton" onClick={this.onTileClicked}>
Jump to message
</AccessibleButton>
<img src="img/cancel-red.svg" className="mx_PinnedEventTile_unpinButton" width="8" height="8"
onClick={this.onUnpinClicked} alt={_t('Unpin Message')} title={_t('Unpin Message')} />
{ unpinButton }
</div>
<MemberAvatar member={sender} width={avatarSize} height={avatarSize} />

View File

@ -20,7 +20,8 @@ limitations under the License.
.mx_PinnedEventsPanel_body {
max-height: 300px;
overflow-y: scroll;
overflow-y: auto;
padding-bottom: 15px;
}
.mx_PinnedEventsPanel_header {