Make sure that syncing members is only happening if they aren't already synced

This commit is contained in:
Damir Jelić
2023-03-01 18:38:50 +01:00
parent 071ba2376e
commit 8550eaeed0
2 changed files with 9 additions and 8 deletions

View File

@@ -391,16 +391,16 @@ impl Common {
}
}
pub(crate) async fn ensure_members(&self) -> Result<()> {
pub(crate) async fn ensure_members(&self) -> Result<Option<MembersResponse>> {
if !self.are_events_visible() {
return Ok(());
return Ok(None);
}
if !self.are_members_synced() {
self.request_members().await?;
self.request_members().await
} else {
Ok(None)
}
Ok(())
}
fn are_events_visible(&self) -> bool {
@@ -417,9 +417,10 @@ impl Common {
/// Sync the member list with the server.
///
/// This method will de-duplicate requests if it is called multiple times in
/// quick succession, in that case the return value will be `None`.
/// quick succession, in that case the return value will be `None`. This
/// method does nothing if the members are already synced.
pub async fn sync_members(&self) -> Result<Option<MembersResponse>> {
self.request_members().await
self.ensure_members().await
}
/// Get active members for this room, includes invited, joined members.

View File

@@ -621,7 +621,7 @@ impl Joined {
);
if !self.are_members_synced() {
self.request_members().await?;
self.ensure_members().await?;
// TODO query keys here?
}