diff --git a/deltachat-ffi/deltachat.h b/deltachat-ffi/deltachat.h index b8204fe44..7dad2cb38 100644 --- a/deltachat-ffi/deltachat.h +++ b/deltachat-ffi/deltachat.h @@ -1084,13 +1084,12 @@ char* dc_get_webxdc_status_updates (dc_context_t* context, uint32_t msg_id, uint /** - * List all webxdc that have updates in the queue + * Return wether webxdc with `msg_id` is updating * @param context The context object. * @param msg_id The ID of the message with the webxdc instance. * @return 1=contact ID is member of chat ID, 0=contact is not in chat - * */ -int dc_get_updating_webxdc (dc_context_t* context, uint32_t chat_id); +int dc_is_webxdc_updating (dc_context_t* context, uint32_t chat_id); /** diff --git a/deltachat-ffi/src/lib.rs b/deltachat-ffi/src/lib.rs index ddd915e46..ff6b00d4a 100644 --- a/deltachat-ffi/src/lib.rs +++ b/deltachat-ffi/src/lib.rs @@ -521,8 +521,7 @@ pub unsafe extern "C" fn dc_event_get_id(event: *mut dc_event_t) -> libc::c_int EventType::SelfavatarChanged => 2110, EventType::WebxdcStatusUpdate { .. } => 2120, EventType::WebxdcInstanceDeleted { .. } => 2121, - EventType::WebxdcBusyUpdating { .. } => 2022, - EventType::WebxdcUpToDate { .. } => 2023, + EventType::WebxdcUpdateStateChanged { .. } => 2022, } } @@ -572,8 +571,7 @@ pub unsafe extern "C" fn dc_event_get_data1_int(event: *mut dc_event_t) -> libc: } EventType::WebxdcStatusUpdate { msg_id, .. } => msg_id.to_u32() as libc::c_int, EventType::WebxdcInstanceDeleted { msg_id, .. } => msg_id.to_u32() as libc::c_int, - EventType::WebxdcBusyUpdating { msg_id } => msg_id.to_u32() as libc::c_int, - EventType::WebxdcUpToDate { msg_id } => msg_id.to_u32() as libc::c_int, + EventType::WebxdcUpdateStateChanged { msg_id, .. } => msg_id.to_u32() as libc::c_int, } } @@ -624,6 +622,10 @@ pub unsafe extern "C" fn dc_event_get_data2_int(event: *mut dc_event_t) -> libc: status_update_serial, .. } => status_update_serial.to_u32() as libc::c_int, + EventType::WebxdcUpdateStateChanged { + is_sending: is_send, + .. + } => *is_send as libc::c_int, } } @@ -668,8 +670,7 @@ pub unsafe extern "C" fn dc_event_get_data2_str(event: *mut dc_event_t) -> *mut | EventType::SelfavatarChanged | EventType::WebxdcStatusUpdate { .. } | EventType::WebxdcInstanceDeleted { .. } - | EventType::WebxdcBusyUpdating { .. } - | EventType::WebxdcUpToDate { .. } + | EventType::WebxdcUpdateStateChanged { .. } | EventType::ChatEphemeralTimerModified { .. } => ptr::null_mut(), EventType::ConfigureProgress { comment, .. } => { if let Some(comment) = comment { diff --git a/deltachat-jsonrpc/src/api/events.rs b/deltachat-jsonrpc/src/api/events.rs index 7d2836ddd..bcd95e9c7 100644 --- a/deltachat-jsonrpc/src/api/events.rs +++ b/deltachat-jsonrpc/src/api/events.rs @@ -283,6 +283,7 @@ pub enum JSONRPCEventType { }, WebxdcBusyUpdating, WebxdcUpToDate, + WebxdcUpdateStateChanged, } impl From for JSONRPCEventType { @@ -383,8 +384,9 @@ impl From for JSONRPCEventType { EventType::WebxdcInstanceDeleted { msg_id } => WebxdcInstanceDeleted { msg_id: msg_id.to_u32(), }, - EventType::WebxdcBusyUpdating { .. } => WebxdcBusyUpdating, - EventType::WebxdcUpToDate { .. } => WebxdcUpToDate, + EventType::WebxdcStatusUpdate { .. } => WebxdcStatusUpdate, + EventType::WebxdcInstanceDeleted { .. } => WebxdcInstanceDeleted, + EventType::WebxdcUpdateStateChanged { .. } => WebxdcUpdateStateChanged, } } } diff --git a/src/events.rs b/src/events.rs index af3437d70..26344dc7c 100644 --- a/src/events.rs +++ b/src/events.rs @@ -319,11 +319,9 @@ pub enum EventType { msg_id: MsgId, }, - WebxdcBusyUpdating { - msg_id: MsgId, - }, - - WebxdcUpToDate { + /// Inform that the webxdc changed its update sending state + WebxdcUpdateStateChanged { msg_id: MsgId, + is_sending: bool, }, } diff --git a/src/webxdc.rs b/src/webxdc.rs index 46cb4f678..aba2eb850 100644 --- a/src/webxdc.rs +++ b/src/webxdc.rs @@ -380,8 +380,9 @@ impl Context { ) .await?; - self.emit_event(EventType::WebxdcBusyUpdating { + self.emit_event(EventType::WebxdcUpdateStateChanged { msg_id: instance.id, + is_sending: true, }); if send_now { @@ -449,7 +450,10 @@ impl Context { } let update_needed_after_sending = get_busy_webxdc_instances(self).await?; for msg_id in update_needed.difference(&update_needed_after_sending) { - self.emit_event(EventType::WebxdcUpToDate { msg_id: *msg_id }) + self.emit_event(EventType::WebxdcUpdateStateChanged { + msg_id: *msg_id, + is_sending: false, + }) } Ok(()) } @@ -2423,14 +2427,30 @@ sth_for_the = "future""# .await?; alice .evtracker - .get_matching(|evt| matches!(evt, EventType::WebxdcBusyUpdating { .. })) + .get_matching(|evt| { + matches!( + evt, + EventType::WebxdcUpdateStateChanged { + is_sending: true, + .. + } + ) + }) .await; alice.flush_status_updates().await?; alice .evtracker - .get_matching(|evt| matches!(evt, EventType::WebxdcUpToDate { .. })) + .get_matching(|evt| { + matches!( + evt, + EventType::WebxdcUpdateStateChanged { + is_sending: false, + .. + } + ) + }) .await; Ok(()) }