ffi: use the Timeline::mark_as_read function in mark_as_read_and_send_read_receipt

This commit is contained in:
Benjamin Bouvier
2024-02-12 16:07:13 +01:00
parent 8eb3fdc9e4
commit e97b7838c5
+6 -10
View File
@@ -551,22 +551,18 @@ impl Room {
}
/// Reverts a previously set unread flag and sends a read receipt to the
/// latest event in the room. Sending read receipts is useful when
/// executing this from the room list but shouldn't be use when entering
/// the room, the timeline should be left to its own devices in that
/// case.
/// latest event in the room.
///
/// Sending read receipts is useful when executing this from the room list
/// but shouldn't be use when entering the room, the timeline should be
/// left to its own devices in that case.
pub async fn mark_as_read_and_send_read_receipt(
&self,
receipt_type: ReceiptType,
) -> Result<(), ClientError> {
let timeline = self.timeline().await?;
if let Some(event) = timeline.latest_event().await {
if let Err(error) = timeline.send_read_receipt(receipt_type, event.event_id().unwrap())
{
error!("Failed to send read receipt: {error}");
}
}
timeline.mark_as_read(receipt_type).await?;
self.mark_as_read().await
}