diff --git a/crates/matrix-sdk/src/room/common.rs b/crates/matrix-sdk/src/room/common.rs index a648d8059..2dd9aa9c0 100644 --- a/crates/matrix-sdk/src/room/common.rs +++ b/crates/matrix-sdk/src/room/common.rs @@ -1,4 +1,4 @@ -use std::{borrow::Borrow, collections::BTreeMap, ops::Deref, sync::Arc, time::Duration}; +use std::{borrow::Borrow, collections::BTreeMap, ops::Deref, sync::Arc}; use matrix_sdk_base::{ deserialized_responses::{MembersResponse, TimelineEvent}, @@ -420,17 +420,6 @@ impl Common { self.request_members().await } - /// Wait for the room to be fully synced. - /// - /// This method makes sure the room that was returned when joining/leaving - /// rooms has been echoed back in the sync. Warning: This waits until a sync - /// happens and does not return if no sync is happening! - pub async fn sync_up(&self) { - while !self.is_synced() { - self.client.inner.sync_beat.listen().wait_timeout(Duration::from_secs(1)); - } - } - /// Get active members for this room, includes invited, joined members. /// /// *Note*: This method will fetch the members from the homeserver if the diff --git a/crates/matrix-sdk/src/room/joined.rs b/crates/matrix-sdk/src/room/joined.rs index e61a98256..13f5c31bf 100644 --- a/crates/matrix-sdk/src/room/joined.rs +++ b/crates/matrix-sdk/src/room/joined.rs @@ -383,6 +383,19 @@ impl Joined { Ok(()) } + /// Wait for the room to be fully synced. + /// + /// This method makes sure the room that was returned when joining a room + /// has been echoed back in the sync. + /// Warning: This waits until a sync happens and does not return if no sync + /// is happening! It can also return early when the room is not a joined + /// room anymore! + pub async fn sync_up(&self) { + while !self.is_synced() && self.room_type() == RoomType::Joined { + self.client.inner.sync_beat.listen().wait_timeout(Duration::from_secs(1)); + } + } + /// Send a room message to this room. /// /// Returns the parsed response from the server.