From feeeb53f1981d8aa20ce7a8b1884e7c02f79b5b0 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Wed, 20 Aug 2025 10:18:13 +0200 Subject: [PATCH] refactor(sdk): Simplify `Client::(joined|invited|left)_rooms`. This patch updates `Client::joined_rooms`, `invited_rooms` and `left_rooms` to re-use `Client::rooms_filtered`. --- crates/matrix-sdk/src/client/mod.rs | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/crates/matrix-sdk/src/client/mod.rs b/crates/matrix-sdk/src/client/mod.rs index 948c323a2..938f3a853 100644 --- a/crates/matrix-sdk/src/client/mod.rs +++ b/crates/matrix-sdk/src/client/mod.rs @@ -1221,29 +1221,17 @@ impl Client { /// Returns the joined rooms this client knows about. pub fn joined_rooms(&self) -> Vec { - self.base_client() - .rooms_filtered(RoomStateFilter::JOINED) - .into_iter() - .map(|room| Room::new(self.clone(), room)) - .collect() + self.rooms_filtered(RoomStateFilter::JOINED) } /// Returns the invited rooms this client knows about. pub fn invited_rooms(&self) -> Vec { - self.base_client() - .rooms_filtered(RoomStateFilter::INVITED) - .into_iter() - .map(|room| Room::new(self.clone(), room)) - .collect() + self.rooms_filtered(RoomStateFilter::INVITED) } /// Returns the left rooms this client knows about. pub fn left_rooms(&self) -> Vec { - self.base_client() - .rooms_filtered(RoomStateFilter::LEFT) - .into_iter() - .map(|room| Room::new(self.clone(), room)) - .collect() + self.rooms_filtered(RoomStateFilter::LEFT) } /// Get a room with the given room id.