Rename display_names -> disambiguated_display_names.
parent
9f34615869
commit
e3cb3566bf
|
@ -176,6 +176,7 @@ mod test {
|
||||||
serde_json::json!({
|
serde_json::json!({
|
||||||
"!roomid:example.com": {
|
"!roomid:example.com": {
|
||||||
"room_id": "!roomid:example.com",
|
"room_id": "!roomid:example.com",
|
||||||
|
"disambiguated_display_names": {},
|
||||||
"room_name": {
|
"room_name": {
|
||||||
"name": null,
|
"name": null,
|
||||||
"canonical_alias": null,
|
"canonical_alias": null,
|
||||||
|
@ -225,6 +226,7 @@ mod test {
|
||||||
let json = serde_json::json!({
|
let json = serde_json::json!({
|
||||||
"!roomid:example.com": {
|
"!roomid:example.com": {
|
||||||
"room_id": "!roomid:example.com",
|
"room_id": "!roomid:example.com",
|
||||||
|
"disambiguated_display_names": {},
|
||||||
"room_name": {
|
"room_name": {
|
||||||
"name": null,
|
"name": null,
|
||||||
"canonical_alias": null,
|
"canonical_alias": null,
|
||||||
|
|
|
@ -181,8 +181,8 @@ pub struct Room {
|
||||||
pub unread_notifications: Option<UInt>,
|
pub unread_notifications: Option<UInt>,
|
||||||
/// The tombstone state of this room.
|
/// The tombstone state of this room.
|
||||||
pub tombstone: Option<Tombstone>,
|
pub tombstone: Option<Tombstone>,
|
||||||
/// The map of display names
|
/// The map of disambiguated display names for users who have the same display name
|
||||||
display_names: HashMap<UserId, String>,
|
disambiguated_display_names: HashMap<UserId, String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RoomName {
|
impl RoomName {
|
||||||
|
@ -281,7 +281,7 @@ impl Room {
|
||||||
unread_highlight: None,
|
unread_highlight: None,
|
||||||
unread_notifications: None,
|
unread_notifications: None,
|
||||||
tombstone: None,
|
tombstone: None,
|
||||||
display_names: HashMap::new(),
|
disambiguated_display_names: HashMap::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -304,7 +304,7 @@ impl Room {
|
||||||
|
|
||||||
/// Get the resolved display name for a member of this room.
|
/// Get the resolved display name for a member of this room.
|
||||||
pub fn member_display_name<'a>(&'a self, id: &UserId) -> Option<Cow<'a, str>> {
|
pub fn member_display_name<'a>(&'a self, id: &UserId) -> Option<Cow<'a, str>> {
|
||||||
self.display_names
|
self.disambiguated_display_names
|
||||||
.get(id)
|
.get(id)
|
||||||
.map(|s| s.as_str().into())
|
.map(|s| s.as_str().into())
|
||||||
.or_else(|| {
|
.or_else(|| {
|
||||||
|
@ -331,7 +331,7 @@ impl Room {
|
||||||
|
|
||||||
// find all users that share the same display name as the joining user
|
// find all users that share the same display name as the joining user
|
||||||
let users_with_same_name: Vec<_> = self
|
let users_with_same_name: Vec<_> = self
|
||||||
.display_names
|
.disambiguated_display_names
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|(_, v)| {
|
.filter(|(_, v)| {
|
||||||
member
|
member
|
||||||
|
@ -363,11 +363,11 @@ impl Room {
|
||||||
|
|
||||||
// update all existing users with same name
|
// update all existing users with same name
|
||||||
for (id, member) in users_with_same_name {
|
for (id, member) in users_with_same_name {
|
||||||
self.display_names.insert(id, member);
|
self.disambiguated_display_names.insert(id, member);
|
||||||
}
|
}
|
||||||
|
|
||||||
// insert new member's display name
|
// insert new member's display name
|
||||||
self.display_names.insert(
|
self.disambiguated_display_names.insert(
|
||||||
member.user_id.clone(),
|
member.user_id.clone(),
|
||||||
member
|
member
|
||||||
.display_name
|
.display_name
|
||||||
|
|
|
@ -154,7 +154,7 @@ mod test {
|
||||||
"own_user_id": "@example:example.com",
|
"own_user_id": "@example:example.com",
|
||||||
"creator": null,
|
"creator": null,
|
||||||
"members": {},
|
"members": {},
|
||||||
"display_names": {},
|
"disambiguated_display_names": {},
|
||||||
"typing_users": [],
|
"typing_users": [],
|
||||||
"power_levels": null,
|
"power_levels": null,
|
||||||
"encrypted": null,
|
"encrypted": null,
|
||||||
|
@ -171,7 +171,7 @@ mod test {
|
||||||
serde_json::json!({
|
serde_json::json!({
|
||||||
"!roomid:example.com": {
|
"!roomid:example.com": {
|
||||||
"room_id": "!roomid:example.com",
|
"room_id": "!roomid:example.com",
|
||||||
"display_names": {},
|
"disambiguated_display_names": {},
|
||||||
"room_name": {
|
"room_name": {
|
||||||
"name": null,
|
"name": null,
|
||||||
"canonical_alias": null,
|
"canonical_alias": null,
|
||||||
|
|
Loading…
Reference in New Issue