mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-02-08 06:32:58 -05:00
The `read_receipts::compute_unread_counts` function needs the _previous events_ to compute the read receipt correctly. These previous events were store in `SlidingSyncRoom::timeline_queue`. Since the removal of `timeline_queue` in the previous patches, this patch uses the Event Cache to fetch them. It only uses events that are loaded in memory. This is as correct as the prior behaviour, even this is still incorrect since it doesn't back-paginate to get a better view. This is for later. The goal of this patch is to restore the same behaviour, without `timeline_queue`. The main problem is that read receipts are computed in `matrix-sdk-base`, and that the Event Cache lives in `matrix-sdk`. Thus, we change the `SlidingSyncResponseProcessor` to handle read receipt in particular. The `matrix_sdk_base::response_processors::rooms::msc4186::extensions::dispa tch_ephemeral_events` function has been split in two methods `dispatch_typing_ephemeral_events`, and `dispatch_receipt_ephemeral_event_for_room`. The workflow has been a little bit redesigned to fit in the new `SlidingSyncResponseProcessor` constraints. This patch moves one test from `matrix-sdk-base` into `matrix-sdk`, because to compute the read receipt, the Event Cache must be enabled/listening to sync updates.