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`.
This commit is contained in:
Ivan Enderlin
2025-08-20 10:18:13 +02:00
parent 1ac876db98
commit feeeb53f19

View File

@@ -1221,29 +1221,17 @@ impl Client {
/// Returns the joined rooms this client knows about.
pub fn joined_rooms(&self) -> Vec<Room> {
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<Room> {
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<Room> {
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.