mirror of
https://github.com/chatmail/core.git
synced 2026-05-20 07:16:31 +03:00
perf: set location for all accounts in parallel
This commit is contained in:
@@ -543,12 +543,16 @@ impl Accounts {
|
|||||||
///
|
///
|
||||||
/// Returns true if location should still be streamed.
|
/// Returns true if location should still be streamed.
|
||||||
pub async fn set_location(&self, latitude: f64, longitude: f64, accuracy: f64) -> Result<bool> {
|
pub async fn set_location(&self, latitude: f64, longitude: f64, accuracy: f64) -> Result<bool> {
|
||||||
let mut continue_streaming = false;
|
let continue_streaming = future::try_join_all(self.accounts.iter().map(
|
||||||
for account in self.accounts.values() {
|
|(account_id, account)| async move {
|
||||||
if location::set(account, latitude, longitude, accuracy).await? {
|
location::set(account, latitude, longitude, accuracy)
|
||||||
continue_streaming = true;
|
.await
|
||||||
}
|
.with_context(|| format!("Failed to set location for account {account_id}"))
|
||||||
}
|
},
|
||||||
|
))
|
||||||
|
.await?
|
||||||
|
.into_iter()
|
||||||
|
.any(|continue_streaming| continue_streaming);
|
||||||
Ok(continue_streaming)
|
Ok(continue_streaming)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user