Try to sync up to 4 times after joining a room
It seems like sometimes one sync isn't enough after sending the join request.
This commit is contained in:
@@ -23,6 +23,7 @@ use matrix_sdk::{
|
|||||||
BaseRoom, Client,
|
BaseRoom, Client,
|
||||||
};
|
};
|
||||||
use serde::de;
|
use serde::de;
|
||||||
|
use tokio::time::sleep;
|
||||||
|
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
|
|
||||||
@@ -81,10 +82,14 @@ pub async fn ensure_room_joined(matrix_client: &Client, room_id: &OwnedRoomOrAli
|
|||||||
.iter()
|
.iter()
|
||||||
.find(|a_room| room_matches(a_room, room_id))
|
.find(|a_room| room_matches(a_room, room_id))
|
||||||
{
|
{
|
||||||
|
info!("Accepting invitation to room {room_id}");
|
||||||
invited.join().await?;
|
invited.join().await?;
|
||||||
} else {
|
} else {
|
||||||
|
info!("Joining room {room_id}");
|
||||||
matrix_client.join_room_by_id_or_alias(room_id, &[]).await?;
|
matrix_client.join_room_by_id_or_alias(room_id, &[]).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _ in 0..4 {
|
||||||
let settings = build_sync_settings().await;
|
let settings = build_sync_settings().await;
|
||||||
matrix_client.sync_once(settings).await?;
|
matrix_client.sync_once(settings).await?;
|
||||||
room = matrix_client
|
room = matrix_client
|
||||||
@@ -92,6 +97,11 @@ pub async fn ensure_room_joined(matrix_client: &Client, room_id: &OwnedRoomOrAli
|
|||||||
.iter()
|
.iter()
|
||||||
.find(|a_room| room_matches(a_room, room_id))
|
.find(|a_room| room_matches(a_room, room_id))
|
||||||
.cloned();
|
.cloned();
|
||||||
|
if room.is_some() {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
sleep(Duration::from_millis(500)).await;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
room.ok_or_else(|| anyhow!("Unable to join room {}", room_id))
|
room.ok_or_else(|| anyhow!("Unable to join room {}", room_id))
|
||||||
|
Reference in New Issue
Block a user