Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 93043c8

Browse files
authored
Merge pull request #2709 from matrix-org/t3chguy/badge_51
Show nearest lower badge, e.g show Mod for 51... etc
2 parents bd577e8 + 9332342 commit 93043c8

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/components/views/rooms/MemberTile.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,21 @@ module.exports = React.createClass({
139139
}
140140
this.member_last_modified_time = member.getLastModifiedTime();
141141

142-
// We deliberately leave power levels that are not 100 or 50 undefined
143-
const powerStatus = {
144-
100: EntityTile.POWER_STATUS_ADMIN,
145-
50: EntityTile.POWER_STATUS_MODERATOR,
146-
}[this.props.member.powerLevel];
142+
const powerStatusMap = new Map([
143+
[100, EntityTile.POWER_STATUS_ADMIN],
144+
[50, EntityTile.POWER_STATUS_MODERATOR],
145+
]);
146+
147+
// Find the nearest power level with a badge
148+
let powerLevel = this.props.member.powerLevel;
149+
for (const [pl] of powerStatusMap) {
150+
if (this.props.member.powerLevel >= pl) {
151+
powerLevel = pl;
152+
break;
153+
}
154+
}
155+
156+
const powerStatus = powerStatusMap.get(powerLevel);
147157

148158
return (
149159
<EntityTile {...this.props} presenceState={presenceState}

0 commit comments

Comments
 (0)