Implement RoomMember::unique_name.
This gives us a name that is as ergonomic as possible while guaranteeing it is unique.master
parent
241d456a81
commit
a0eaa9c364
|
@ -109,6 +109,17 @@ impl RoomMember {
|
||||||
.unwrap_or_else(|| format!("{}", self.user_id))
|
.unwrap_or_else(|| format!("{}", self.user_id))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns a name for the member which is guaranteed to be unique.
|
||||||
|
///
|
||||||
|
/// This is either of the format "DISPLAY_NAME (MXID)" if the display name is set for the
|
||||||
|
/// member, or simply "MXID" if not.
|
||||||
|
pub fn unique_name(&self) -> String {
|
||||||
|
self.display_name
|
||||||
|
.clone()
|
||||||
|
.map(|d| format!("{} ({})", d, self.user_id))
|
||||||
|
.unwrap_or_else(|| format!("{}", self.user_id))
|
||||||
|
}
|
||||||
|
|
||||||
pub fn update_member(&mut self, event: &MemberEvent) -> bool {
|
pub fn update_member(&mut self, event: &MemberEvent) -> bool {
|
||||||
use MembershipChange::*;
|
use MembershipChange::*;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue