mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-16 13:14:58 +08:00
do self membership checks with getMyMembership elsewhere as well
This commit is contained in:
parent
c38b286e8e
commit
860c6355f0
@ -497,12 +497,11 @@ function canSendEvent(event, roomId) {
|
|||||||
sendError(event, _t('This room is not recognised.'));
|
sendError(event, _t('This room is not recognised.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const me = client.credentials.userId;
|
if (room.getMyMembership() !== "join") {
|
||||||
const member = room.getMember(me);
|
|
||||||
if (!member || member.membership !== "join") {
|
|
||||||
sendError(event, _t('You are not in this room.'));
|
sendError(event, _t('You are not in this room.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const me = client.credentials.userId;
|
||||||
|
|
||||||
let canSend = false;
|
let canSend = false;
|
||||||
if (isState) {
|
if (isState) {
|
||||||
|
@ -346,20 +346,18 @@ module.exports = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
const myMember = this.props.room.getMember(
|
const myMembership = this.props.room.getMyMembership();
|
||||||
MatrixClientPeg.get().credentials.userId,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Can't set notif level or tags on non-join rooms
|
// Can't set notif level or tags on non-join rooms
|
||||||
if (myMember.membership !== 'join') {
|
if (myMembership !== 'join') {
|
||||||
return this._renderLeaveMenu(myMember.membership);
|
return this._renderLeaveMenu(myMembership);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{ this._renderNotifMenu() }
|
{ this._renderNotifMenu() }
|
||||||
<hr className="mx_RoomTileContextMenu_separator" />
|
<hr className="mx_RoomTileContextMenu_separator" />
|
||||||
{ this._renderLeaveMenu(myMember.membership) }
|
{ this._renderLeaveMenu(myMembership) }
|
||||||
<hr className="mx_RoomTileContextMenu_separator" />
|
<hr className="mx_RoomTileContextMenu_separator" />
|
||||||
{ this._renderRoomTagMenu() }
|
{ this._renderRoomTagMenu() }
|
||||||
</div>
|
</div>
|
||||||
|
@ -794,15 +794,15 @@ module.exports = React.createClass({
|
|||||||
}
|
}
|
||||||
|
|
||||||
let leaveButton = null;
|
let leaveButton = null;
|
||||||
const myMember = this.props.room.getMember(myUserId);
|
const myMemberShip = this.props.room.getMyMembership();
|
||||||
if (myMember) {
|
if (myMemberShip) {
|
||||||
if (myMember.membership === "join") {
|
if (myMemberShip === "join") {
|
||||||
leaveButton = (
|
leaveButton = (
|
||||||
<AccessibleButton className="mx_RoomSettings_leaveButton" onClick={this.onLeaveClick}>
|
<AccessibleButton className="mx_RoomSettings_leaveButton" onClick={this.onLeaveClick}>
|
||||||
{ _t('Leave room') }
|
{ _t('Leave room') }
|
||||||
</AccessibleButton>
|
</AccessibleButton>
|
||||||
);
|
);
|
||||||
} else if (myMember.membership === "leave") {
|
} else if (myMemberShip === "leave") {
|
||||||
leaveButton = (
|
leaveButton = (
|
||||||
<AccessibleButton className="mx_RoomSettings_leaveButton" onClick={this.onForgetClick}>
|
<AccessibleButton className="mx_RoomSettings_leaveButton" onClick={this.onForgetClick}>
|
||||||
{ _t('Forget room') }
|
{ _t('Forget room') }
|
||||||
|
Loading…
Reference in New Issue
Block a user