diff --git a/deltachat-ffi/deltachat.h b/deltachat-ffi/deltachat.h index 48d9a60de..76d7dfb00 100644 --- a/deltachat-ffi/deltachat.h +++ b/deltachat-ffi/deltachat.h @@ -3157,6 +3157,10 @@ void dc_accounts_maybe_network_lost (dc_accounts_t* accounts); * * dc_accounts_background_fetch() was created for the iOS Background fetch. * + * The `DC_EVENT_ACCOUNTS_BACKGROUND_FETCH_DONE` event is emitted at the end, + * process all events until you get this one and you can safely return to the background + * without forgeting to create notifications caused by timing race conditions. + * * @memberof dc_accounts_t * @param timeout The timeout in seconds * @return Return 1 on success and 0 on failure (like timeout) @@ -6278,7 +6282,7 @@ void dc_event_unref(dc_event_t* event); * This event is only emitted by the account manager */ -#define DC_EVENT_BACKGROUND_FETCH_COMPLETED_FOR_ALL_ACCOUNTS 2200 +#define DC_EVENT_ACCOUNTS_BACKGROUND_FETCH_DONE 2200 /** * @} diff --git a/deltachat-jsonrpc/src/api.rs b/deltachat-jsonrpc/src/api.rs index 749bf0064..48a1e42a9 100644 --- a/deltachat-jsonrpc/src/api.rs +++ b/deltachat-jsonrpc/src/api.rs @@ -232,6 +232,10 @@ impl CommandApi { } /// Performs a background fetch for all accounts in parallel with a timeout. + /// + /// The `BackgroundFetchCompletedForAllAccounts` event is emitted at the end, + /// process all events until you get this one and you can safely return to the background + /// without forgeting to create notifications caused by timing race conditions. async fn background_fetch_for_all_accounts(&self, timeout_in_seconds: f64) -> Result<()> { self.accounts .write() diff --git a/node/lib/constants.ts b/node/lib/constants.ts index 5c4c3b42d..2fe4f9af5 100644 --- a/node/lib/constants.ts +++ b/node/lib/constants.ts @@ -29,7 +29,7 @@ export enum C { DC_DOWNLOAD_FAILURE = 20, DC_DOWNLOAD_IN_PROGRESS = 1000, DC_DOWNLOAD_UNDECIPHERABLE = 30, - DC_EVENT_BACKGROUND_FETCH_COMPLETED_FOR_ALL_ACCOUNTS = 2200, + DC_EVENT_ACCOUNTS_BACKGROUND_FETCH_DONE = 2200, DC_EVENT_CHAT_EPHEMERAL_TIMER_MODIFIED = 2021, DC_EVENT_CHAT_MODIFIED = 2020, DC_EVENT_CONFIGURE_PROGRESS = 2041, @@ -327,5 +327,5 @@ export const EventId2EventName: { [key: number]: string } = { 2111: 'DC_EVENT_CONFIG_SYNCED', 2120: 'DC_EVENT_WEBXDC_STATUS_UPDATE', 2121: 'DC_EVENT_WEBXDC_INSTANCE_DELETED', - 2200: 'DC_EVENT_BACKGROUND_FETCH_COMPLETED_FOR_ALL_ACCOUNTS', + 2200: 'DC_EVENT_ACCOUNTS_BACKGROUND_FETCH_DONE', } diff --git a/src/accounts.rs b/src/accounts.rs index c3977bbeb..9ea09d5f3 100644 --- a/src/accounts.rs +++ b/src/accounts.rs @@ -295,6 +295,10 @@ impl Accounts { /// Performs a background fetch for all accounts in parallel. /// /// If you need a timeout, then use [Accounts::background_fetch_with_timeout] instead. + /// + /// The `BackgroundFetchCompletedForAllAccounts` event is emitted at the end, + /// process all events until you get this one and you can safely return to the background + /// without forgeting to create notifications caused by timing race conditions. pub async fn background_fetch(&self) { async fn background_fetch_and_log_error(account: Context) { if let Err(error) = account.background_fetch().await { @@ -316,6 +320,10 @@ impl Accounts { /// Performs a background fetch for all accounts in parallel with a timeout. /// /// If you want no timeout, then use [Accounts::background_fetch] instead. + /// + /// The `BackgroundFetchCompletedForAllAccounts` event is emitted at the end, + /// process all events until you get this one and you can safely return to the background + /// without forgeting to create notifications caused by timing race conditions. pub async fn background_fetch_with_timeout(&self, timeout: std::time::Duration) -> Result<()> { let result = tokio::time::timeout(timeout, self.background_fetch()).await; self.emit_event(EventType::BackgroundFetchCompletedForAllAccounts);