matrix-sdk: Allow users to get a reference to the store.
parent
a4e7dc1042
commit
6f35a05311
|
@ -40,7 +40,9 @@ use zeroize::Zeroizing;
|
|||
use tracing::{debug, warn};
|
||||
use tracing::{error, info, instrument};
|
||||
|
||||
use matrix_sdk_base::{responses::SyncResponse, BaseClient, BaseClientConfig, Room, Session};
|
||||
use matrix_sdk_base::{
|
||||
responses::SyncResponse, BaseClient, BaseClientConfig, Room, Session, Store,
|
||||
};
|
||||
|
||||
#[cfg(feature = "encryption")]
|
||||
use matrix_sdk_base::crypto::{
|
||||
|
@ -504,6 +506,11 @@ impl Client {
|
|||
Ok(response.avatar_url)
|
||||
}
|
||||
|
||||
/// Get a reference to the store.
|
||||
pub fn store(&self) -> &Store {
|
||||
self.base_client.store()
|
||||
}
|
||||
|
||||
/// Sets the mxc avatar url of the client's owner. The avatar gets unset if `url` is `None`.
|
||||
pub async fn set_avatar_url(&self, url: Option<&str>) -> Result<()> {
|
||||
let user_id = self.user_id().await.ok_or(Error::AuthenticationRequired)?;
|
||||
|
|
|
@ -66,7 +66,7 @@ compile_error!("only one of 'native-tls' or 'rustls-tls' features can be enabled
|
|||
#[cfg(feature = "encryption")]
|
||||
#[cfg_attr(feature = "docs", doc(cfg(encryption)))]
|
||||
pub use matrix_sdk_base::crypto::LocalTrust;
|
||||
pub use matrix_sdk_base::{Error as BaseError, Room, RoomMember, Session};
|
||||
pub use matrix_sdk_base::{Error as BaseError, Room, RoomInfo, RoomMember, Session};
|
||||
|
||||
pub use matrix_sdk_common::*;
|
||||
pub use reqwest;
|
||||
|
|
|
@ -32,7 +32,7 @@ use matrix_sdk_common::{
|
|||
room::member::MemberEventContent, AnyBasicEvent, AnyStrippedStateEvent, AnySyncRoomEvent,
|
||||
AnySyncStateEvent, StateEvent, SyncStateEvent,
|
||||
},
|
||||
identifiers::{RoomId, UserId, room_id},
|
||||
identifiers::{room_id, RoomId, UserId},
|
||||
locks::RwLock,
|
||||
Raw,
|
||||
};
|
||||
|
@ -350,6 +350,11 @@ impl BaseClient {
|
|||
&self.session
|
||||
}
|
||||
|
||||
/// Get a reference to the store.
|
||||
pub fn store(&self) -> &Store {
|
||||
&self.store
|
||||
}
|
||||
|
||||
/// Is the client logged in.
|
||||
pub async fn logged_in(&self) -> bool {
|
||||
// TODO turn this into a atomic bool so this method doesn't need to be
|
||||
|
|
|
@ -49,7 +49,7 @@ mod rooms;
|
|||
mod session;
|
||||
mod store;
|
||||
|
||||
pub use rooms::{RoomInfo, Room, RoomMember};
|
||||
pub use rooms::{Room, RoomInfo, RoomMember};
|
||||
pub use store::Store;
|
||||
|
||||
pub use client::{BaseClient, BaseClientConfig, RoomState, RoomStateType};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
mod joined;
|
||||
mod members;
|
||||
|
||||
pub use joined::{RoomInfo, Room, RoomType};
|
||||
pub use joined::{Room, RoomInfo, RoomType};
|
||||
pub use members::RoomMember;
|
||||
|
|
|
@ -337,7 +337,9 @@ impl Store {
|
|||
|
||||
pub async fn get_room_infos(&self) -> impl Stream<Item = RoomInfo> {
|
||||
stream::iter(
|
||||
self.room_summaries.iter().map(|r| serde_json::from_slice(&r.unwrap().1).unwrap())
|
||||
self.room_summaries
|
||||
.iter()
|
||||
.map(|r| serde_json::from_slice(&r.unwrap().1).unwrap()),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue