Fix space admin check false positive on multiple admins
This commit is contained in:
parent
d026dce723
commit
2fc3662830
1 changed files with 7 additions and 2 deletions
|
@ -131,8 +131,13 @@ interface IProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
const isOnlyAdmin = (room: Room): boolean => {
|
const isOnlyAdmin = (room: Room): boolean => {
|
||||||
return !room.getJoinedMembers().some(member => {
|
const userId = room.client.getUserId();
|
||||||
return member.userId !== room.client.credentials.userId && member.powerLevelNorm === 100;
|
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;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue