perf: set location for all accounts in parallel

This commit is contained in:
link2xt
2026-04-26 23:29:44 +02:00
parent 411158d045
commit 2f70a02d4c

View File

@@ -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)
} }