Skip to content

Commit

Permalink
!temp
Browse files Browse the repository at this point in the history
  • Loading branch information
Hywan committed Dec 17, 2024
1 parent 09aa15b commit d6a71b9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 17 deletions.
13 changes: 2 additions & 11 deletions crates/matrix-sdk-ui/src/timeline/event_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1097,19 +1097,10 @@ impl<'a, 'o> TimelineEventHandler<'a, 'o> {
);

match &self.ctx.flow {
Flow::Local { txn_id, .. } => {
Flow::Local { .. } => {
trace!("Adding new local timeline item");

let removed_duplicated_timeline_item = Self::deduplicate_local_timeline_item(
&mut self.items,
&mut item,
None,
Some(&txn_id),
&self.meta,
&self.settings,
);
let item =
Self::new_timeline_item(&mut self.meta, item, removed_duplicated_timeline_item);
let item = Self::new_timeline_item(&mut self.meta, item, None);

self.items.push_back(item, None);
}
Expand Down
6 changes: 4 additions & 2 deletions crates/matrix-sdk-ui/tests/integration/timeline/echo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,18 @@ async fn test_echo() {
server.reset().await;

// Local echo is replaced with the remote echo.
assert_next_matches!(timeline_stream, VectorDiff::Remove { index: 1 });
let remote_echo =
assert_next_matches!(timeline_stream, VectorDiff::Set { index: 1, value } => value);
assert_next_matches!(timeline_stream, VectorDiff::PushFront { value } => value);
let item = remote_echo.as_event().unwrap();
assert!(item.is_own());
assert_eq!(item.timestamp(), MilliSecondsSinceUnixEpoch(uint!(152038280)));

// The date divider is also replaced.
let date_divider =
assert_next_matches!(timeline_stream, VectorDiff::Set { index: 0, value } => value);
assert_next_matches!(timeline_stream, VectorDiff::PushFront { value } => value);
assert!(date_divider.is_date_divider());
assert_next_matches!(timeline_stream, VectorDiff::Remove { index: 2 });
}

#[async_test]
Expand Down
9 changes: 5 additions & 4 deletions crates/matrix-sdk-ui/tests/integration/timeline/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -508,20 +508,21 @@ async fn test_no_duplicate_date_divider() {
assert_eq!(value.event_id().unwrap(), "$PyHxV5mYzjetBUT3qZq7V95GOzxb02EP");
});

// The second message is replaced -> [First DD Second]
assert_next_matches!(timeline_stream, VectorDiff::Set { index: 2, value } => {
// The second message is replaced -> [First Second DD]
assert_next_matches!(timeline_stream, VectorDiff::Remove { index: 2 });
assert_next_matches!(timeline_stream, VectorDiff::Insert { index: 1, value } => {
let value = value.as_event().unwrap();
assert_eq!(value.content().as_message().unwrap().body(), "Second.");
assert_eq!(value.event_id().unwrap(), "$5E2kLK/Sg342bgBU9ceEIEPYpbFaqJpZ");
});

// A new date divider is inserted -> [DD First DD Second]
// A new date divider is inserted -> [DD First Second DD]
assert_next_matches!(timeline_stream, VectorDiff::PushFront { value } => {
assert!(value.is_date_divider());
});

// The useless date divider is removed. -> [DD First Second]
assert_next_matches!(timeline_stream, VectorDiff::Remove { index: 2 });
assert_next_matches!(timeline_stream, VectorDiff::Remove { index: 3 });

assert_pending!(timeline_stream);
}

0 comments on commit d6a71b9

Please sign in to comment.