diff --git a/crates/matrix-sdk-base/src/rooms/normal.rs b/crates/matrix-sdk-base/src/rooms/normal.rs index 124e922ba..fdd4f5b44 100644 --- a/crates/matrix-sdk-base/src/rooms/normal.rs +++ b/crates/matrix-sdk-base/src/rooms/normal.rs @@ -116,8 +116,11 @@ pub struct RoomSummary { /// /// This was called `heroes` and contained raw `String`s of the `UserId` /// before; changing the field's name helped with avoiding a migration. - #[serde(default)] + #[serde(default, skip_serializing_if = "Vec::is_empty")] pub(crate) heroes_user_ids: Vec, + /// The heroes names, as returned by a server, if available. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub(crate) heroes_names: Vec, /// The number of members that are considered to be joined to the room. pub(crate) joined_member_count: u64, /// The number of members that are considered to be invited to the room. @@ -1135,8 +1138,9 @@ impl RoomInfo { } /// Updates the heroes user ids. - pub(crate) fn update_heroes(&mut self, heroes: Vec) { + pub(crate) fn update_heroes(&mut self, heroes: Vec, names: Vec) { self.summary.heroes_user_ids = heroes; + self.summary.heroes_names = names; } /// The number of active members (invited + joined) in the room. @@ -1471,6 +1475,7 @@ mod tests { }, summary: RoomSummary { heroes_user_ids: vec![owned_user_id!("@somebody:example.org")], + heroes_names: vec![], joined_member_count: 5, invited_member_count: 0, }, @@ -1556,6 +1561,7 @@ mod tests { }, "summary": { "heroes_user_ids": ["@somebody:example.org"], + "heroes_names": ["Somebody"], "joined_member_count": 5, "invited_member_count": 0, }, @@ -1586,6 +1592,7 @@ mod tests { assert_eq!(info.notification_counts.highlight_count, 1); assert_eq!(info.notification_counts.notification_count, 2); assert_eq!(info.summary.heroes_user_ids, vec![owned_user_id!("@somebody:example.org")]); + assert_eq!(info.summary.heroes_names, vec!["Somebody".to_owned()]); assert_eq!(info.summary.joined_member_count, 5); assert_eq!(info.summary.invited_member_count, 0); assert!(info.members_synced); diff --git a/crates/matrix-sdk-base/src/sliding_sync.rs b/crates/matrix-sdk-base/src/sliding_sync.rs index 91d4dd7ba..f7e3de2a8 100644 --- a/crates/matrix-sdk-base/src/sliding_sync.rs +++ b/crates/matrix-sdk-base/src/sliding_sync.rs @@ -38,7 +38,7 @@ use crate::RoomMemberships; use crate::{ error::Result, read_receipts::{compute_unread_counts, PreviousEventsProvider}, - rooms::{normal::RoomSummary, RoomState}, + rooms::{RoomState}, store::{ambiguity_map::AmbiguityCache, StateChanges, Store}, sync::{JoinedRoomUpdate, LeftRoomUpdate, Notification, RoomUpdates, SyncResponse}, Room, RoomInfo, @@ -703,9 +703,10 @@ fn process_room_properties(room_data: &v4::SlidingSyncRoom, room_info: &mut Room } if let Some(heroes) = &room_data.heroes { - // Filter out all the heroes which don't have a user id. + // Filter out all the heroes which don't have a user id or name. room_info.update_heroes( heroes.iter().filter_map(|hero| hero.user_id.as_ref()).cloned().collect(), + heroes.iter().filter_map(|hero| hero.name.as_ref()).cloned().collect(), ); }