timeline: remove duplicate set_fully_read_event that does the same as handle_fully_read_marker

This commit is contained in:
Benjamin Bouvier
2024-07-10 14:56:29 +02:00
parent 54c037ed03
commit 9e9df163b9
3 changed files with 7 additions and 18 deletions

View File

@@ -609,7 +609,7 @@ impl<P: RoomDataProvider> TimelineInner<P> {
if let Some(fully_read_event_id) =
self.room_data_provider.load_fully_read_marker().await
{
state.set_fully_read_event(fully_read_event_id);
state.handle_fully_read_marker(fully_read_event_id);
}
}
}
@@ -857,11 +857,6 @@ impl<P: RoomDataProvider> TimelineInner<P> {
true
}
#[cfg(test)]
pub(super) async fn set_fully_read_event(&self, fully_read_event_id: OwnedEventId) {
self.state.write().await.set_fully_read_event(fully_read_event_id);
}
#[cfg(feature = "e2e-encryption")]
#[instrument(skip(self, room), fields(room_id = ?room.room_id()))]
pub(super) async fn retry_event_decryption(

View File

@@ -347,12 +347,6 @@ impl TimelineInnerState {
Ok(())
}
pub(super) fn set_fully_read_event(&mut self, fully_read_event_id: OwnedEventId) {
let mut txn = self.transaction();
txn.set_fully_read_event(fully_read_event_id);
txn.commit();
}
#[cfg(test)]
pub(super) fn handle_read_receipts(
&mut self,

View File

@@ -106,7 +106,7 @@ async fn test_update_read_marker() {
let day_divider = assert_next_matches!(stream, VectorDiff::PushFront { value } => value);
assert!(day_divider.is_day_divider());
timeline.inner.set_fully_read_event(first_event_id.clone()).await;
timeline.inner.handle_fully_read_marker(first_event_id.clone()).await;
// Nothing should happen, the marker cannot be added at the end.
@@ -118,7 +118,7 @@ async fn test_update_read_marker() {
let item = assert_next_matches!(stream, VectorDiff::Insert { index: 2, value } => value);
assert_matches!(item.as_virtual(), Some(VirtualTimelineItem::ReadMarker));
timeline.inner.set_fully_read_event(second_event_id.clone()).await;
timeline.inner.handle_fully_read_marker(second_event_id.clone()).await;
// The read marker is removed but not reinserted, because it cannot be added at
// the end.
@@ -133,20 +133,20 @@ async fn test_update_read_marker() {
assert_matches!(marker.kind, TimelineItemKind::Virtual(VirtualTimelineItem::ReadMarker));
// Nothing should happen if the fully read event is set back to an older event.
timeline.inner.set_fully_read_event(first_event_id).await;
timeline.inner.handle_fully_read_marker(first_event_id).await;
// Nothing should happen if the fully read event isn't found.
timeline.inner.set_fully_read_event(event_id!("$fake_event_id").to_owned()).await;
timeline.inner.handle_fully_read_marker(event_id!("$fake_event_id").to_owned()).await;
// Nothing should happen if the fully read event is referring to an event
// that has already been marked as fully read.
timeline.inner.set_fully_read_event(second_event_id).await;
timeline.inner.handle_fully_read_marker(second_event_id).await;
timeline.handle_live_message_event(&ALICE, RoomMessageEventContent::text_plain("D")).await;
let item = assert_next_matches!(stream, VectorDiff::PushBack { value } => value);
item.as_event().unwrap();
timeline.inner.set_fully_read_event(third_event_id).await;
timeline.inner.handle_fully_read_marker(third_event_id).await;
// The read marker is moved after the third event.
assert_next_matches!(stream, VectorDiff::Remove { index: 3 });