From 2fc36628308bbc4a3949faf93f837c0272d4843c Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 17 Sep 2021 09:38:59 +0100 Subject: [PATCH] Fix space admin check false positive on multiple admins --- src/components/views/dialogs/LeaveSpaceDialog.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/components/views/dialogs/LeaveSpaceDialog.tsx b/src/components/views/dialogs/LeaveSpaceDialog.tsx index 841fa144079..d26c0a8b6a2 100644 --- a/src/components/views/dialogs/LeaveSpaceDialog.tsx +++ b/src/components/views/dialogs/LeaveSpaceDialog.tsx @@ -131,8 +131,13 @@ interface IProps { } const isOnlyAdmin = (room: Room): boolean => { - return !room.getJoinedMembers().some(member => { - return member.userId !== room.client.credentials.userId && member.powerLevelNorm === 100; + const userId = room.client.getUserId(); + if (room.getMember(userId).powerLevelNorm !== 100) { + return false; // user is not an admin + } + return room.getJoinedMembers().every(member => { + // return true if every other member has a lower power level (we are highest) + return member.userId === userId || member.powerLevelNorm < 100; }); };