From 885cceb8f3b0742220b27fefae148284215c4ee2 Mon Sep 17 00:00:00 2001 From: Johannes Marbach Date: Thu, 27 Nov 2025 12:54:58 +0100 Subject: [PATCH] docs(timeline): clarify what mark_as_read actually does Signed-off-by: Johannes Marbach --- bindings/matrix-sdk-ffi/src/timeline/mod.rs | 19 +++++++++++----- crates/matrix-sdk-ui/src/timeline/mod.rs | 24 +++++++++++++++------ 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/bindings/matrix-sdk-ffi/src/timeline/mod.rs b/bindings/matrix-sdk-ffi/src/timeline/mod.rs index c5f6ab21478..5f28a68bf2a 100644 --- a/bindings/matrix-sdk-ffi/src/timeline/mod.rs +++ b/bindings/matrix-sdk-ffi/src/timeline/mod.rs @@ -354,12 +354,21 @@ impl Timeline { Ok(()) } - /// Mark the room as read by trying to attach an *unthreaded* read receipt - /// to the latest room event. + /// Mark the timeline as read by attempting to send a read receipt on the + /// latest visible event. /// - /// This works even if the latest event belongs to a thread, as a threaded - /// reply also belongs to the unthreaded timeline. No threaded receipt - /// will be sent here (see also #3123). + /// The latest visible event is determined from the timeline's focus kind + /// and whether or not it hides threaded events. If no latest event can + /// be determined and the timeline is live, the room's unread marker is + /// unset instead. + /// + /// # Arguments + /// + /// * `receipt_type` - The type of receipt to send. When using + /// [`ReceiptType::FullyRead`], an unthreaded receipt will be sent. This + /// works even if the latest event belongs to a thread, as a threaded + /// reply also belongs to the unthreaded timeline. Otherwise the receipt + /// thread will be determined based on the timeline's focus kind. pub async fn mark_as_read(&self, receipt_type: ReceiptType) -> Result<(), ClientError> { self.inner.mark_as_read(receipt_type.into()).await?; Ok(()) diff --git a/crates/matrix-sdk-ui/src/timeline/mod.rs b/crates/matrix-sdk-ui/src/timeline/mod.rs index 8e4f407f1c1..4ed4c6ba14c 100644 --- a/crates/matrix-sdk-ui/src/timeline/mod.rs +++ b/crates/matrix-sdk-ui/src/timeline/mod.rs @@ -788,16 +788,26 @@ impl Timeline { Ok(()) } - /// Mark the room as read by sending an unthreaded read receipt on the - /// latest event, be it visible or not. + /// Mark the timeline as read by attempting to send a read receipt on the + /// latest visible event. /// - /// This works even if the latest event belongs to a thread, as a threaded - /// reply also belongs to the unthreaded timeline. No threaded receipt - /// will be sent here (see also #3123). + /// The latest visible event is determined from the timeline's focus kind + /// and whether or not it hides threaded events. If no latest event can + /// be determined and the timeline is live, the room's unread marker is + /// unset instead. /// - /// This also unsets the unread marker of the room if necessary. + /// # Arguments /// - /// Returns a boolean indicating if it sent the receipt or not. + /// * `receipt_type` - The type of receipt to send. When using + /// [`ReceiptType::FullyRead`], an unthreaded receipt will be sent. This + /// works even if the latest event belongs to a thread, as a threaded + /// reply also belongs to the unthreaded timeline. Otherwise the + /// [`ReceiptThread`] will be determined based on the timeline's focus + /// kind. + /// + /// # Returns + /// + /// A boolean indicating if the receipt was sent or not. #[instrument(skip(self), fields(room_id = ?self.room().room_id()))] pub async fn mark_as_read(&self, receipt_type: ReceiptType) -> Result { if let Some(event_id) = self.controller.latest_event_id().await {