client: Add a method to get all known rooms

master
Damir Jelić 2021-03-02 14:58:30 +01:00
parent 123772c524
commit 8f481dd859
1 changed files with 9 additions and 1 deletions

View File

@ -41,7 +41,8 @@ use tracing::{error, info, instrument};
use matrix_sdk_base::{ use matrix_sdk_base::{
deserialized_responses::{MembersResponse, SyncResponse}, deserialized_responses::{MembersResponse, SyncResponse},
BaseClient, BaseClientConfig, EventHandler, InvitedRoom, JoinedRoom, LeftRoom, Session, Store, BaseClient, BaseClientConfig, EventHandler, InvitedRoom, JoinedRoom, LeftRoom, RoomState,
Session, Store,
}; };
#[cfg(feature = "encryption")] #[cfg(feature = "encryption")]
@ -560,6 +561,13 @@ impl Client {
self.base_client.set_event_handler(handler).await; self.base_client.set_event_handler(handler).await;
} }
/// Get all the rooms the client knows about.
///
/// This will return the list of joined, invited, and left rooms.
pub fn rooms(&self) -> Vec<RoomState> {
self.store().get_rooms()
}
/// Returns the joined rooms this client knows about. /// Returns the joined rooms this client knows about.
pub fn joined_rooms(&self) -> Vec<JoinedRoom> { pub fn joined_rooms(&self) -> Vec<JoinedRoom> {
self.store() self.store()