Skip to content

Commit

Permalink
!fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
Hywan committed Jun 10, 2024
1 parent 17f9e2a commit ba9359c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 21 deletions.
2 changes: 1 addition & 1 deletion crates/matrix-sdk-ui/src/timeline/event_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1122,7 +1122,7 @@ impl<'a, 'o> TimelineEventHandler<'a, 'o> {
// The event index maps to a timeline item index!
event_meta.timeline_item_index = Some(timeline_item_index);

// Shift all timeline item index to the right after `timeline_item_index`!
// Shift all timeline item indices to the right after `timeline_item_index`!
for event_meta in &mut self.meta.all_events {
if let Some(index) = event_meta.timeline_item_index.as_mut() {
if *index >= timeline_item_index {
Expand Down
35 changes: 15 additions & 20 deletions crates/matrix-sdk-ui/tests/integration/timeline/pagination.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,26 +84,7 @@ async fn test_back_pagination() {
};
join(paginate, observe_paginating).await;

let message = assert_next_matches!(
timeline_stream,
VectorDiff::PushBack { value } => value
);
assert_let!(TimelineItemContent::Message(msg) = message.as_event().unwrap().content());
assert_let!(MessageType::Text(text) = msg.msgtype());
assert_eq!(text.body, "hello world");

let message = assert_next_matches!(
timeline_stream,
VectorDiff::PushFront { value } => value
);
assert_let!(TimelineItemContent::Message(msg) = message.as_event().unwrap().content());
assert_let!(MessageType::Text(text) = msg.msgtype());
assert_eq!(text.body, "the world is big");

let message = assert_next_matches!(
timeline_stream,
VectorDiff::PushFront { value } => value
);
assert_let!(Some(VectorDiff::PushBack { value: message }) = timeline_stream.next().await);
assert_let!(TimelineItemContent::OtherState(state) = message.as_event().unwrap().content());
assert_eq!(state.state_key(), "");
assert_let!(
Expand All @@ -115,6 +96,20 @@ async fn test_back_pagination() {
assert_eq!(content.name, "New room name");
assert_eq!(prev_content.as_ref().unwrap().name.as_ref().unwrap(), "Old room name");

// Read receipt.
assert_let!(Some(VectorDiff::Set { index: 0, value: message }) = timeline_stream.next().await);
assert_let!(TimelineItemContent::OtherState(_) = message.as_event().unwrap().content());

assert_let!(Some(VectorDiff::PushBack { value: message }) = timeline_stream.next().await);
assert_let!(TimelineItemContent::Message(msg) = message.as_event().unwrap().content());
assert_let!(MessageType::Text(text) = msg.msgtype());
assert_eq!(text.body, "the world is big");

assert_let!(Some(VectorDiff::PushBack { value: message }) = timeline_stream.next().await);
assert_let!(TimelineItemContent::Message(msg) = message.as_event().unwrap().content());
assert_let!(MessageType::Text(text) = msg.msgtype());
assert_eq!(text.body, "hello world");

let day_divider = assert_next_matches!(
timeline_stream,
VectorDiff::PushFront { value } => value
Expand Down

0 comments on commit ba9359c

Please sign in to comment.