mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-14 19:16:02 -04:00
fix: Make sure room.sync_up works under all conditions
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user