mirror of
https://github.com/chatmail/core.git
synced 2026-04-26 18:06:35 +03:00
BackgroundFetchCompletedForAllAccounts event
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user