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

Commit

Permalink
Merge pull request #2709 from matrix-org/t3chguy/badge_51
Browse files Browse the repository at this point in the history
Show nearest lower badge, e.g show Mod for 51... etc
  • Loading branch information
turt2live authored Feb 28, 2019
2 parents bd577e8 + 9332342 commit 93043c8
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/components/views/rooms/MemberTile.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,21 @@ module.exports = React.createClass({
}
this.member_last_modified_time = member.getLastModifiedTime();

// We deliberately leave power levels that are not 100 or 50 undefined
const powerStatus = {
100: EntityTile.POWER_STATUS_ADMIN,
50: EntityTile.POWER_STATUS_MODERATOR,
}[this.props.member.powerLevel];
const powerStatusMap = new Map([
[100, EntityTile.POWER_STATUS_ADMIN],
[50, EntityTile.POWER_STATUS_MODERATOR],
]);

// Find the nearest power level with a badge
let powerLevel = this.props.member.powerLevel;
for (const [pl] of powerStatusMap) {
if (this.props.member.powerLevel >= pl) {
powerLevel = pl;
break;
}
}

const powerStatus = powerStatusMap.get(powerLevel);

return (
<EntityTile {...this.props} presenceState={presenceState}
Expand Down

0 comments on commit 93043c8

Please sign in to comment.