rename event also in core

This commit is contained in:
Simon Laux
2024-01-13 11:40:02 +01:00
committed by bjoern
parent 060c9c8aa1
commit de86b8a96e
5 changed files with 12 additions and 14 deletions

View File

@@ -559,7 +559,7 @@ pub unsafe extern "C" fn dc_event_get_id(event: *mut dc_event_t) -> libc::c_int
EventType::ConfigSynced { .. } => 2111,
EventType::WebxdcStatusUpdate { .. } => 2120,
EventType::WebxdcInstanceDeleted { .. } => 2121,
EventType::BackgroundFetchCompletedForAllAccounts => 2200,
EventType::AccountsBackgroundFetchDone => 2200,
}
}
@@ -588,7 +588,7 @@ pub unsafe extern "C" fn dc_event_get_data1_int(event: *mut dc_event_t) -> libc:
| EventType::ConfigSynced { .. }
| EventType::IncomingMsgBunch { .. }
| EventType::ErrorSelfNotInGroup(_)
| EventType::BackgroundFetchCompletedForAllAccounts => 0,
| EventType::AccountsBackgroundFetchDone => 0,
EventType::MsgsChanged { chat_id, .. }
| EventType::ReactionsChanged { chat_id, .. }
| EventType::IncomingMsg { chat_id, .. }
@@ -648,7 +648,7 @@ pub unsafe extern "C" fn dc_event_get_data2_int(event: *mut dc_event_t) -> libc:
| EventType::WebxdcInstanceDeleted { .. }
| EventType::IncomingMsgBunch { .. }
| EventType::SelfavatarChanged
| EventType::BackgroundFetchCompletedForAllAccounts
| EventType::AccountsBackgroundFetchDone
| EventType::ConfigSynced { .. } => 0,
EventType::ChatModified(_) => 0,
EventType::MsgsChanged { msg_id, .. }
@@ -711,7 +711,7 @@ pub unsafe extern "C" fn dc_event_get_data2_str(event: *mut dc_event_t) -> *mut
| EventType::SelfavatarChanged
| EventType::WebxdcStatusUpdate { .. }
| EventType::WebxdcInstanceDeleted { .. }
| EventType::BackgroundFetchCompletedForAllAccounts
| EventType::AccountsBackgroundFetchDone
| EventType::ChatEphemeralTimerModified { .. } => ptr::null_mut(),
EventType::ConfigureProgress { comment, .. } => {
if let Some(comment) = comment {

View File

@@ -233,7 +233,7 @@ impl CommandApi {
/// Performs a background fetch for all accounts in parallel with a timeout.
///
/// The `BackgroundFetchCompletedForAllAccounts` event is emitted at the end,
/// The `AccountsBackgroundFetchDone` 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<()> {

View File

@@ -251,7 +251,7 @@ pub enum EventType {
/// that all events emitted during the background fetch were processed.
///
/// This event is only emitted by the account manager
BackgroundFetchCompletedForAllAccounts,
AccountsBackgroundFetchDone,
}
impl From<CoreEventType> for EventType {
@@ -360,9 +360,7 @@ impl From<CoreEventType> for EventType {
CoreEventType::WebxdcInstanceDeleted { msg_id } => WebxdcInstanceDeleted {
msg_id: msg_id.to_u32(),
},
CoreEventType::BackgroundFetchCompletedForAllAccounts => {
BackgroundFetchCompletedForAllAccounts
}
CoreEventType::AccountsBackgroundFetchDone => AccountsBackgroundFetchDone,
}
}
}

View File

@@ -296,7 +296,7 @@ impl Accounts {
///
/// If you need a timeout, then use [Accounts::background_fetch_with_timeout] instead.
///
/// The `BackgroundFetchCompletedForAllAccounts` event is emitted at the end,
/// The `AccountsBackgroundFetchDone` 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) {
@@ -314,19 +314,19 @@ impl Accounts {
)
.await;
self.emit_event(EventType::BackgroundFetchCompletedForAllAccounts);
self.emit_event(EventType::AccountsBackgroundFetchDone);
}
/// 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,
/// The `AccountsBackgroundFetchDone` 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);
self.emit_event(EventType::AccountsBackgroundFetchDone);
result.map_err(|err| err.into())
}

View File

@@ -293,5 +293,5 @@ pub enum EventType {
/// that all events emitted during the background fetch were processed.
///
/// This event is only emitted by the account manager
BackgroundFetchCompletedForAllAccounts,
AccountsBackgroundFetchDone,
}