core icon indicating copy to clipboard operation
core copied to clipboard

WIP: api!: add `LIMIT` arg to `get_chat_media`

Open WofWca opened this issue 2 months ago • 3 comments

In Delta Chat desktop we show the 3 recently used WebXDC apps, which relies on get_chat_media, which is quite expensive. Hopefully adding LIMIT 3 makes it faster.

https://github.com/deltachat/deltachat-desktop/blob/d32e85ec1353730a512cbdfff6c9c4dba5816dd4/packages/frontend/src/components/screens/MainScreen/MainScreen.tsx#L170-L181

Marking this as a breaking change because it's breaking TypeScript-wise, but shouldn't be breaking behavior-wise, because not providing the argument in JSON-RPC should be equivalent to providing null (which gets converted to None).

TODO:

  • [ ] Add to CFFI?
  • [ ] Docs. Both the core fn and the JSON-RPC.

WofWca avatar Oct 20 '25 15:10 WofWca

related to the need to provide null in typescript for Option::None: https://github.com/chatmail/yerpc/issues/10

Simon-Laux avatar Oct 20 '25 15:10 Simon-Laux

Alternatively there could be another jsonrpc api just for the purpose of returning the last 3 webxdc apps. jsonrpc apis are easy to create compared to cffi api. (Could potentially be optimized even more than adding an option to the existing api, because it could be implemented differently under the hood)

Simon-Laux avatar Oct 20 '25 15:10 Simon-Laux

please do some measurements on some slow chats before merging or diving into details. it is not always the case that a LIMIT makes things significantly faster.

eg. ORDER BY and SELECT may still needed to be done on whole data set; LIMIT is more often useful when it comes to remote connections, less often on local connections. but as said, measurement will tell

r10s avatar Oct 20 '25 19:10 r10s