From 0e7a731d6170861c8fc464863d5136c77cbb2c04 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 18 Feb 2021 15:19:16 +0000 Subject: [PATCH] Make use of new room canInvite helper --- src/components/views/rooms/MemberList.js | 12 +----------- src/components/views/rooms/NewRoomIntro.tsx | 9 +-------- 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/src/components/views/rooms/MemberList.js b/src/components/views/rooms/MemberList.js index 9da6e22847..495a0f0d2c 100644 --- a/src/components/views/rooms/MemberList.js +++ b/src/components/views/rooms/MemberList.js @@ -450,17 +450,7 @@ export default class MemberList extends React.Component { let inviteButton; if (room && room.getMyMembership() === 'join') { - // assume we can invite until proven false - 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; - } - } + const canInvite = room.canInvite(cli.getUserId()); let inviteButtonText = _t("Invite to this room"); const chat = CommunityPrototypeStore.instance.getSelectedCommunityGeneralChat(); diff --git a/src/components/views/rooms/NewRoomIntro.tsx b/src/components/views/rooms/NewRoomIntro.tsx index 9be3d6be18..ce426a64ed 100644 --- a/src/components/views/rooms/NewRoomIntro.tsx +++ b/src/components/views/rooms/NewRoomIntro.tsx @@ -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; - if (canInvite) { + if (room.canInvite(cli.getUserId())) { const onInviteClick = () => { dis.dispatch({ action: "view_invite", roomId }); };