deltachat / deltachat-core-rust

Delta Chat Rust Core library, used by Android/iOS/desktop apps, bindings and bots 📧
https://delta.chat/en/contribute
Other
637 stars 82 forks source link

Webxdc: add ffi to get "update sending state" #3320

Open r10s opened 2 years ago

r10s commented 2 years ago

currently, the end-user of an Webxdc has no good idea about whether all updates are sent out or not.

the idea is to let the UI show a similar online indicator as in the bubbles - so a rotating circle or so when there is sth. pending and a checkmark when all update messages are sent.

the indicator should not be shown by the Webxdc itself, but just by the implementation, a good place seems to be right of the title that is shown in all UI anyway. the .xdc does not need to be adapted then.

technically, we could add a separate ffi or enhance dc_msg_get_webxdc_info().

Septias commented 2 years ago

I wouldn't show an arrow when there are no more updates to be send, because it has no benefit (If there is no spinning circle then it's obvious that no more messages are in the queue) and only clutters the view.

r10s commented 2 years ago

additional notes:

so, maybe generalize these cases to sth. as dc_msg_get_upload_state() or dc_msg_is_all_work_done() (the latter wording is already known by dc_accounts_t).

Septias commented 1 year ago

Is there a way to transport a promise over ffi-boundaries? Because if we just add a normal ffi-funkcion or enhance dc_msg_get_webxdc_info() we have to bussily wait for smtp-requests to finish. This seems like a waste of ressources.

I know that there is a way to transport Promises in webassembly, but I'm not sure about ours

Edit: I've taken a closer look at our setup and I guess I'm writing something event-based since that seems to be the taken approach

r10s commented 1 year ago

Is there a way to transport a promise over ffi-boundaries?

not really, we have to do that over events.

i suggest to do it similar to dc_get_connectivity():

  1. having a function to query the "update sending state" instantly (without network involved, but that should be doable as we could check the corresponding tables)
  2. plus an event that indicates that the "update sending state" has changed.