use anyhow::Result;
use matrix_sdk::Client;
use matrix_sdk::ruma;
pub fn is_logged_in(client: &Client) -> bool {
client.user_id().is_some()
}
pub fn current_user_id(client: &Client) -> Option<ruma::OwnedUserId> {
client.user_id().map(|u| u.to_owned())
}
pub fn current_device_id(client: &Client) -> Option<ruma::OwnedDeviceId> {
client.device_id().map(|d| d.to_owned())
}
pub async fn logout(client: &Client) -> Result<()> {
client.matrix_auth().logout().await?;
crate::persistence::matrix_state::clear_session().await?;
tracing::info!("Logged out successfully");
Ok(())
}