Do not start sync thread if user is disconnected

This commit is contained in:
2025-11-19 10:49:26 +01:00
parent 79d4482ea4
commit 5bf7c7f8df
2 changed files with 12 additions and 0 deletions

View File

@@ -298,6 +298,11 @@ impl MatrixClient {
Ok(()) Ok(())
} }
/// Check whether a user is currently connected to this client or not
pub fn is_client_connected(&self) -> bool {
self.client.is_active()
}
/// Disconnect user from client /// Disconnect user from client
pub async fn disconnect(self) -> anyhow::Result<()> { pub async fn disconnect(self) -> anyhow::Result<()> {
if let Err(e) = self.client.logout().await { if let Err(e) = self.client.logout().await {

View File

@@ -102,6 +102,13 @@ impl Actor for MatrixManagerActor {
return Ok(()); return Ok(());
}; };
if !client.is_client_connected() {
log::warn!(
"Cannot start sync thread for {email:?} because Matrix account is not set!"
);
return Ok(());
}
// Start thread // Start thread
log::debug!("Starting sync thread for {email:?}"); log::debug!("Starting sync thread for {email:?}");
let thread_id = let thread_id =