From d2c61dc90e3324b63062ee3b775eac57a1b2b811 Mon Sep 17 00:00:00 2001 From: Simon Laux Date: Tue, 12 Dec 2023 01:26:10 +0100 Subject: [PATCH] api: jsonrpc: add `background_fetch_for_all_accounts` --- deltachat-jsonrpc/src/api.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/deltachat-jsonrpc/src/api.rs b/deltachat-jsonrpc/src/api.rs index fb8a2166b..749bf0064 100644 --- a/deltachat-jsonrpc/src/api.rs +++ b/deltachat-jsonrpc/src/api.rs @@ -231,6 +231,16 @@ impl CommandApi { Ok(()) } + /// Performs a background fetch for all accounts in parallel with a timeout. + async fn background_fetch_for_all_accounts(&self, timeout_in_seconds: f64) -> Result<()> { + self.accounts + .write() + .await + .background_fetch_with_timeout(std::time::Duration::from_secs_f64(timeout_in_seconds)) + .await?; + Ok(()) + } + // --------------------------------------------- // Methods that work on individual accounts // ---------------------------------------------