File tree Expand file tree Collapse file tree 4 files changed +19
-3
lines changed Expand file tree Collapse file tree 4 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -3157,6 +3157,10 @@ void dc_accounts_maybe_network_lost (dc_accounts_t* accounts);
3157
3157
*
3158
3158
* dc_accounts_background_fetch() was created for the iOS Background fetch.
3159
3159
*
3160
+ * The `DC_EVENT_ACCOUNTS_BACKGROUND_FETCH_DONE` event is emitted at the end,
3161
+ * process all events until you get this one and you can safely return to the background
3162
+ * without forgeting to create notifications caused by timing race conditions.
3163
+ *
3160
3164
* @memberof dc_accounts_t
3161
3165
* @param timeout The timeout in seconds
3162
3166
* @return Return 1 on success and 0 on failure (like timeout)
@@ -6278,7 +6282,7 @@ void dc_event_unref(dc_event_t* event);
6278
6282
* This event is only emitted by the account manager
6279
6283
*/
6280
6284
6281
- #define DC_EVENT_BACKGROUND_FETCH_COMPLETED_FOR_ALL_ACCOUNTS 2200
6285
+ #define DC_EVENT_ACCOUNTS_BACKGROUND_FETCH_DONE 2200
6282
6286
6283
6287
/**
6284
6288
* @}
Original file line number Diff line number Diff line change @@ -232,6 +232,10 @@ impl CommandApi {
232
232
}
233
233
234
234
/// Performs a background fetch for all accounts in parallel with a timeout.
235
+ ///
236
+ /// The `BackgroundFetchCompletedForAllAccounts` event is emitted at the end,
237
+ /// process all events until you get this one and you can safely return to the background
238
+ /// without forgeting to create notifications caused by timing race conditions.
235
239
async fn background_fetch_for_all_accounts ( & self , timeout_in_seconds : f64 ) -> Result < ( ) > {
236
240
self . accounts
237
241
. write ( )
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ export enum C {
29
29
DC_DOWNLOAD_FAILURE = 20 ,
30
30
DC_DOWNLOAD_IN_PROGRESS = 1000 ,
31
31
DC_DOWNLOAD_UNDECIPHERABLE = 30 ,
32
- DC_EVENT_BACKGROUND_FETCH_COMPLETED_FOR_ALL_ACCOUNTS = 2200 ,
32
+ DC_EVENT_ACCOUNTS_BACKGROUND_FETCH_DONE = 2200 ,
33
33
DC_EVENT_CHAT_EPHEMERAL_TIMER_MODIFIED = 2021 ,
34
34
DC_EVENT_CHAT_MODIFIED = 2020 ,
35
35
DC_EVENT_CONFIGURE_PROGRESS = 2041 ,
@@ -327,5 +327,5 @@ export const EventId2EventName: { [key: number]: string } = {
327
327
2111 : 'DC_EVENT_CONFIG_SYNCED' ,
328
328
2120 : 'DC_EVENT_WEBXDC_STATUS_UPDATE' ,
329
329
2121 : 'DC_EVENT_WEBXDC_INSTANCE_DELETED' ,
330
- 2200 : 'DC_EVENT_BACKGROUND_FETCH_COMPLETED_FOR_ALL_ACCOUNTS ' ,
330
+ 2200 : 'DC_EVENT_ACCOUNTS_BACKGROUND_FETCH_DONE ' ,
331
331
}
Original file line number Diff line number Diff line change @@ -295,6 +295,10 @@ impl Accounts {
295
295
/// Performs a background fetch for all accounts in parallel.
296
296
///
297
297
/// If you need a timeout, then use [Accounts::background_fetch_with_timeout] instead.
298
+ ///
299
+ /// The `BackgroundFetchCompletedForAllAccounts` event is emitted at the end,
300
+ /// process all events until you get this one and you can safely return to the background
301
+ /// without forgeting to create notifications caused by timing race conditions.
298
302
pub async fn background_fetch ( & self ) {
299
303
async fn background_fetch_and_log_error ( account : Context ) {
300
304
if let Err ( error) = account. background_fetch ( ) . await {
@@ -316,6 +320,10 @@ impl Accounts {
316
320
/// Performs a background fetch for all accounts in parallel with a timeout.
317
321
///
318
322
/// If you want no timeout, then use [Accounts::background_fetch] instead.
323
+ ///
324
+ /// The `BackgroundFetchCompletedForAllAccounts` event is emitted at the end,
325
+ /// process all events until you get this one and you can safely return to the background
326
+ /// without forgeting to create notifications caused by timing race conditions.
319
327
pub async fn background_fetch_with_timeout ( & self , timeout : std:: time:: Duration ) -> Result < ( ) > {
320
328
let result = tokio:: time:: timeout ( timeout, self . background_fetch ( ) ) . await ;
321
329
self . emit_event ( EventType :: BackgroundFetchCompletedForAllAccounts ) ;
You can’t perform that action at this time.
0 commit comments