base: Add a method to get either the display name or the localpart of an user
This commit is contained in:
parent
0c81f3d9ae
commit
b995492457
1 changed files with 8 additions and 0 deletions
|
@ -47,6 +47,14 @@ impl RoomMember {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn name(&self) -> &str {
|
||||
if let Some(d) = self.display_name() {
|
||||
d
|
||||
} else {
|
||||
self.user_id().localpart()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn normalized_power_level(&self) -> i64 {
|
||||
if self.max_power_level > 0 {
|
||||
(self.power_level() * 100) / self.max_power_level
|
||||
|
|
Loading…
Reference in a new issue