Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions crates/matrix-sdk-ui/src/timeline/controller/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1012,11 +1012,20 @@ impl<P: RoomDataProvider> TimelineController<P> {
.await;
}

if track_read_markers
&& let Some(fully_read_event_id) =
if track_read_markers {
if let Some(fully_read_event_id) =
self.room_data_provider.load_fully_read_marker().await
{
state.handle_fully_read_marker(fully_read_event_id);
{
state.handle_fully_read_marker(fully_read_event_id);
} else if let Some((last_read_event_id, _)) = state
.meta
.read_receipts
.get_latest(self.room_data_provider.own_user_id(), &ReceiptType::Read)
.cloned()
{
// Fall back to read receipt if no fully read marker exists.
state.handle_fully_read_marker(last_read_event_id);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl ReadReceipts {

/// Read the latest read receipt of the given type for the given user, from
/// the in-memory cache.
fn get_latest(
pub(crate) fn get_latest(
&self,
user_id: &UserId,
receipt_type: &ReceiptType,
Expand Down
10 changes: 8 additions & 2 deletions crates/matrix-sdk-ui/tests/integration/timeline/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use matrix_sdk_test::{
};
use matrix_sdk_ui::timeline::{
RoomExt as _, TimelineBuilder, TimelineDetails, TimelineEventItemId, TimelineFocus,
VirtualTimelineItem,
};
use ruma::{
MilliSecondsSinceUnixEpoch,
Expand Down Expand Up @@ -1719,11 +1720,16 @@ async fn test_send_read_receipts() {
assert_eq!(ev.event_id(), Some(event_id!("$2")));
assert!(ev.read_receipts().is_empty());

let ev = initial_items[3].as_event().unwrap();
// Since the room has no `m.fully_read` event, the read marker falls back to
// the normal read receipt.
let ev = initial_items[3].as_virtual().unwrap();
assert!(matches!(ev, VirtualTimelineItem::ReadMarker));

let ev = initial_items[4].as_event().unwrap();
assert_eq!(ev.event_id(), Some(event_id!("$3")));
assert!(ev.read_receipts().is_empty());

let ev = initial_items[4].as_event().unwrap();
let ev = initial_items[5].as_event().unwrap();
assert_eq!(ev.event_id(), Some(event_id!("$4")));
let rr = ev.read_receipts();
assert_eq!(rr.len(), 1);
Expand Down
Loading