From 3a70b2e8abb1a076d1ffdd95daf20d3a33d53015 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Fri, 16 Jun 2023 09:44:36 +0200 Subject: [PATCH] fix(ui): `SlidingSync::subscribe_to_room` marks room as having missing members. Fix https://github.com/matrix-org/matrix-rust-sdk/issues/2004. --- crates/matrix-sdk-base/src/rooms/normal.rs | 7 ++++++- crates/matrix-sdk/src/sliding_sync/mod.rs | 7 +++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/crates/matrix-sdk-base/src/rooms/normal.rs b/crates/matrix-sdk-base/src/rooms/normal.rs index 0f30ca2f484..6d6fe672db5 100644 --- a/crates/matrix-sdk-base/src/rooms/normal.rs +++ b/crates/matrix-sdk-base/src/rooms/normal.rs @@ -146,6 +146,11 @@ impl Room { self.inner.read().unwrap().members_synced } + /// Mark this Room is still missing member information. + pub fn mark_members_missing(&self) { + self.inner.write().unwrap().mark_members_missing() + } + /// Check if the room states have been synced /// /// States might be missing if we have only seen the room_id of this Room @@ -680,7 +685,7 @@ impl RoomInfo { self.members_synced = true; } - /// Mark this Room still missing member information. + /// Mark this Room is still missing member information. pub fn mark_members_missing(&mut self) { self.members_synced = false; } diff --git a/crates/matrix-sdk/src/sliding_sync/mod.rs b/crates/matrix-sdk/src/sliding_sync/mod.rs index ad15699bfc6..fe0cad0fab2 100644 --- a/crates/matrix-sdk/src/sliding_sync/mod.rs +++ b/crates/matrix-sdk/src/sliding_sync/mod.rs @@ -134,7 +134,14 @@ impl SlidingSync { } /// Subscribe to a given room. + /// + /// If the associated [`Room`] exists, it will be marked as members are + /// missing, so that it ensures to re-fetch all members. pub fn subscribe_to_room(&self, room_id: OwnedRoomId, settings: Option) { + if let Some(room) = self.inner.client.get_room(&room_id) { + room.mark_members_missing(); + } + self.inner .sticky .write()