From eb5af4287f7b74b6a15f4b9e5fb3a51d4bf021a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Commaille?= Date: Fri, 9 Jun 2023 10:27:43 +0200 Subject: [PATCH] sdk: Allow to get rooms filtered by room state MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Kévin Commaille --- crates/matrix-sdk/CHANGELOG.md | 1 + crates/matrix-sdk/src/client/mod.rs | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/crates/matrix-sdk/CHANGELOG.md b/crates/matrix-sdk/CHANGELOG.md index 05fa09de5..16cd76e3d 100644 --- a/crates/matrix-sdk/CHANGELOG.md +++ b/crates/matrix-sdk/CHANGELOG.md @@ -14,6 +14,7 @@ for invited rooms too. - Add `Client::subscribe_to_room_updates` and `room::Common::subscribe_to_updates` - `Client::rooms` now returns all rooms, even invited, as advertised. +- Add `Client::rooms_filtered` # 0.6.2 diff --git a/crates/matrix-sdk/src/client/mod.rs b/crates/matrix-sdk/src/client/mod.rs index 19d8ab10d..3ba0cca1a 100644 --- a/crates/matrix-sdk/src/client/mod.rs +++ b/crates/matrix-sdk/src/client/mod.rs @@ -887,6 +887,15 @@ impl Client { .collect() } + /// Get all the rooms the client knows about, filtered by room state. + pub fn rooms_filtered(&self, filter: RoomStateFilter) -> Vec { + self.base_client() + .get_rooms_filtered(filter) + .into_iter() + .map(|room| room::Common::new(self.clone(), room).into()) + .collect() + } + /// Returns the joined rooms this client knows about. pub fn joined_rooms(&self) -> Vec { self.base_client()