Show when you've been kicked or banned
Update the room state when you've been kicked or banned, and show a message in the preview bar, including the reason.
This commit is contained in:
parent
775834b707
commit
de4773ba93
2 changed files with 55 additions and 6 deletions
|
@ -159,6 +159,7 @@ module.exports = React.createClass({
|
||||||
MatrixClientPeg.get().on("Room.name", this.onRoomName);
|
MatrixClientPeg.get().on("Room.name", this.onRoomName);
|
||||||
MatrixClientPeg.get().on("Room.accountData", this.onRoomAccountData);
|
MatrixClientPeg.get().on("Room.accountData", this.onRoomAccountData);
|
||||||
MatrixClientPeg.get().on("RoomState.members", this.onRoomStateMember);
|
MatrixClientPeg.get().on("RoomState.members", this.onRoomStateMember);
|
||||||
|
MatrixClientPeg.get().on("RoomMember.membership", this.onRoomMemberMembership);
|
||||||
MatrixClientPeg.get().on("accountData", this.onAccountData);
|
MatrixClientPeg.get().on("accountData", this.onAccountData);
|
||||||
|
|
||||||
this.tabComplete = new TabComplete({
|
this.tabComplete = new TabComplete({
|
||||||
|
@ -347,6 +348,7 @@ module.exports = React.createClass({
|
||||||
MatrixClientPeg.get().removeListener("Room.name", this.onRoomName);
|
MatrixClientPeg.get().removeListener("Room.name", this.onRoomName);
|
||||||
MatrixClientPeg.get().removeListener("Room.accountData", this.onRoomAccountData);
|
MatrixClientPeg.get().removeListener("Room.accountData", this.onRoomAccountData);
|
||||||
MatrixClientPeg.get().removeListener("RoomState.members", this.onRoomStateMember);
|
MatrixClientPeg.get().removeListener("RoomState.members", this.onRoomStateMember);
|
||||||
|
MatrixClientPeg.get().removeListener("RoomMember.membership", this.onRoomMemberMembership);
|
||||||
MatrixClientPeg.get().removeListener("accountData", this.onAccountData);
|
MatrixClientPeg.get().removeListener("accountData", this.onAccountData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -612,6 +614,12 @@ module.exports = React.createClass({
|
||||||
this._updateRoomMembers();
|
this._updateRoomMembers();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onRoomMemberMembership: function(ev, member, oldMembership) {
|
||||||
|
if (member.userId == MatrixClientPeg.get().credentials.userId) {
|
||||||
|
this.forceUpdate();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
// rate limited because a power level change will emit an event for every
|
// rate limited because a power level change will emit an event for every
|
||||||
// member in the room.
|
// member in the room.
|
||||||
_updateRoomMembers: new rate_limited_func(function() {
|
_updateRoomMembers: new rate_limited_func(function() {
|
||||||
|
@ -1456,6 +1464,7 @@ module.exports = React.createClass({
|
||||||
/>
|
/>
|
||||||
<div className="mx_RoomView_auxPanel">
|
<div className="mx_RoomView_auxPanel">
|
||||||
<RoomPreviewBar onJoinClick={ this.onJoinButtonClicked }
|
<RoomPreviewBar onJoinClick={ this.onJoinButtonClicked }
|
||||||
|
onForgetClick={ this.onForgetClick }
|
||||||
onRejectClick={ this.onRejectThreepidInviteButtonClicked }
|
onRejectClick={ this.onRejectThreepidInviteButtonClicked }
|
||||||
canPreview={ false } error={ this.state.roomLoadError }
|
canPreview={ false } error={ this.state.roomLoadError }
|
||||||
roomAlias={room_alias}
|
roomAlias={room_alias}
|
||||||
|
@ -1498,6 +1507,7 @@ module.exports = React.createClass({
|
||||||
/>
|
/>
|
||||||
<div className="mx_RoomView_auxPanel">
|
<div className="mx_RoomView_auxPanel">
|
||||||
<RoomPreviewBar onJoinClick={ this.onJoinButtonClicked }
|
<RoomPreviewBar onJoinClick={ this.onJoinButtonClicked }
|
||||||
|
onForgetClick={ this.onForgetClick }
|
||||||
onRejectClick={ this.onRejectButtonClicked }
|
onRejectClick={ this.onRejectButtonClicked }
|
||||||
inviterName={ inviterName }
|
inviterName={ inviterName }
|
||||||
canPreview={ false }
|
canPreview={ false }
|
||||||
|
@ -1573,6 +1583,7 @@ module.exports = React.createClass({
|
||||||
}
|
}
|
||||||
aux = (
|
aux = (
|
||||||
<RoomPreviewBar onJoinClick={this.onJoinButtonClicked}
|
<RoomPreviewBar onJoinClick={this.onJoinButtonClicked}
|
||||||
|
onForgetClick={ this.onForgetClick }
|
||||||
onRejectClick={this.onRejectThreepidInviteButtonClicked}
|
onRejectClick={this.onRejectThreepidInviteButtonClicked}
|
||||||
spinner={this.state.joining}
|
spinner={this.state.joining}
|
||||||
inviterName={inviterName}
|
inviterName={inviterName}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2015, 2016 OpenMarket Ltd
|
Copyright 2015, 2016 OpenMarket Ltd
|
||||||
|
Copyright 2017 Vector Creations Ltd
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
@ -79,6 +80,12 @@ module.exports = React.createClass({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_roomNameElement: function(fallback) {
|
||||||
|
fallback = fallback || 'a room';
|
||||||
|
const name = this.props.room ? this.props.room.name : (this.props.room_alias || "");
|
||||||
|
return name ? <b>{ name }</b> : fallback;
|
||||||
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
var joinBlock, previewBlock;
|
var joinBlock, previewBlock;
|
||||||
|
|
||||||
|
@ -89,6 +96,16 @@ module.exports = React.createClass({
|
||||||
</div>);
|
</div>);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const myMember = this.props.room ? this.props.room.currentState.members[
|
||||||
|
MatrixClientPeg.get().credentials.userId
|
||||||
|
] : null;
|
||||||
|
const kicked = (
|
||||||
|
myMember &&
|
||||||
|
myMember.membership == 'leave' &&
|
||||||
|
myMember.events.member.getSender() != MatrixClientPeg.get().credentials.userId
|
||||||
|
);
|
||||||
|
const banned = myMember && myMember.membership == 'ban';
|
||||||
|
|
||||||
if (this.props.inviterName) {
|
if (this.props.inviterName) {
|
||||||
var emailMatchBlock;
|
var emailMatchBlock;
|
||||||
if (this.props.invitedEmail) {
|
if (this.props.invitedEmail) {
|
||||||
|
@ -122,8 +139,31 @@ module.exports = React.createClass({
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
} else if (kicked || banned) {
|
||||||
|
const verb = kicked ? 'kicked' : 'banned';
|
||||||
|
const roomName = this._roomNameElement('this room');
|
||||||
|
const kicker = MatrixClientPeg.get().getUser(
|
||||||
|
myMember.events.member.getSender()
|
||||||
|
);
|
||||||
|
let reason;
|
||||||
|
if (myMember.events.member.getContent().reason) {
|
||||||
|
reason = <div>Reason: {myMember.events.member.getContent().reason}</div>
|
||||||
}
|
}
|
||||||
else if (this.props.error) {
|
let rejoinBlock;
|
||||||
|
if (!banned) {
|
||||||
|
rejoinBlock = <a onClick={ this.props.onJoinClick }><b>Rejoin</b></a>;
|
||||||
|
}
|
||||||
|
joinBlock = (
|
||||||
|
<div>
|
||||||
|
<div className="mx_RoomPreviewBar_join_text">
|
||||||
|
You have been {verb} from {roomName} by {kicker.displayName}.<br />
|
||||||
|
{reason}
|
||||||
|
<a onClick={ this.props.onForgetClick }><b>Forget</b></a><br />
|
||||||
|
{rejoinBlock}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
} else if (this.props.error) {
|
||||||
var name = this.props.roomAlias || "This room";
|
var name = this.props.roomAlias || "This room";
|
||||||
var error;
|
var error;
|
||||||
if (this.props.error.errcode == 'M_NOT_FOUND') {
|
if (this.props.error.errcode == 'M_NOT_FOUND') {
|
||||||
|
@ -138,10 +178,8 @@ module.exports = React.createClass({
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
} else {
|
||||||
else {
|
const name = this._roomNameElement();
|
||||||
var name = this.props.room ? this.props.room.name : (this.props.room_alias || "");
|
|
||||||
name = name ? <b>{ name }</b> : "a room";
|
|
||||||
joinBlock = (
|
joinBlock = (
|
||||||
<div>
|
<div>
|
||||||
<div className="mx_RoomPreviewBar_join_text">
|
<div className="mx_RoomPreviewBar_join_text">
|
||||||
|
|
Loading…
Reference in a new issue