Make use of new room canInvite helper
This commit is contained in:
parent
e1acf11e67
commit
0e7a731d61
2 changed files with 2 additions and 19 deletions
|
@ -450,17 +450,7 @@ export default class MemberList extends React.Component {
|
||||||
let inviteButton;
|
let inviteButton;
|
||||||
|
|
||||||
if (room && room.getMyMembership() === 'join') {
|
if (room && room.getMyMembership() === 'join') {
|
||||||
// assume we can invite until proven false
|
const canInvite = room.canInvite(cli.getUserId());
|
||||||
let canInvite = true;
|
|
||||||
|
|
||||||
const plEvent = room.currentState.getStateEvents("m.room.power_levels", "");
|
|
||||||
const me = room.getMember(cli.getUserId());
|
|
||||||
if (plEvent && me) {
|
|
||||||
const content = plEvent.getContent();
|
|
||||||
if (content && content.invite > me.powerLevel) {
|
|
||||||
canInvite = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let inviteButtonText = _t("Invite to this room");
|
let inviteButtonText = _t("Invite to this room");
|
||||||
const chat = CommunityPrototypeStore.instance.getSelectedCommunityGeneralChat();
|
const chat = CommunityPrototypeStore.instance.getSelectedCommunityGeneralChat();
|
||||||
|
|
|
@ -100,15 +100,8 @@ const NewRoomIntro = () => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let canInvite = inRoom;
|
|
||||||
const powerLevels = room.currentState.getStateEvents(EventType.RoomPowerLevels, "")?.getContent();
|
|
||||||
const me = room.getMember(cli.getUserId());
|
|
||||||
if (powerLevels && me && powerLevels.invite > me.powerLevel) {
|
|
||||||
canInvite = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
let buttons;
|
let buttons;
|
||||||
if (canInvite) {
|
if (room.canInvite(cli.getUserId())) {
|
||||||
const onInviteClick = () => {
|
const onInviteClick = () => {
|
||||||
dis.dispatch({ action: "view_invite", roomId });
|
dis.dispatch({ action: "view_invite", roomId });
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue