BackgroundFetchCompletedForAllAccounts event

This commit is contained in:
Simon Laux
2024-01-04 07:27:08 +01:00
committed by bjoern
parent 946eea4c9e
commit df455bbcf5
8 changed files with 42 additions and 4 deletions

View File

@@ -309,14 +309,17 @@ impl Accounts {
.map(background_fetch_and_log_error),
)
.await;
self.emit_event(EventType::BackgroundFetchCompletedForAllAccounts);
}
/// Performs a background fetch for all accounts in parallel with a timeout.
///
/// If you want no timeout, then use [Accounts::background_fetch] instead.
pub async fn background_fetch_with_timeout(&self, timeout: std::time::Duration) -> Result<()> {
tokio::time::timeout(timeout, self.background_fetch()).await?;
Ok(())
let result = tokio::time::timeout(timeout, self.background_fetch()).await;
self.emit_event(EventType::BackgroundFetchCompletedForAllAccounts);
result.map_err(|err| err.into())
}
/// Emits a single event.

View File

@@ -287,4 +287,11 @@ pub enum EventType {
/// ID of the deleted message.
msg_id: MsgId,
},
/// Tells that the Background fetch was completed (or timed out).
/// This event acts as a marker, when you reach this event you can be sure
/// that all events emitted during the background fetch were processed.
///
/// This event is only emitted by the account manager
BackgroundFetchCompletedForAllAccounts,
}