diff --git a/crates/matrix-sdk-ui/src/timeline/inner.rs b/crates/matrix-sdk-ui/src/timeline/inner.rs index 321304d3d..808bd8739 100644 --- a/crates/matrix-sdk-ui/src/timeline/inner.rs +++ b/crates/matrix-sdk-ui/src/timeline/inner.rs @@ -697,7 +697,8 @@ impl TimelineInner

{ let new_item = item.with_inner_kind(local_item.with_send_state(EventSendState::NotSentYet)); let content = item.content.clone(); - state.items.set(idx, new_item); + state.items.remove(idx); + state.items.push_back(new_item); Some(content) } diff --git a/crates/matrix-sdk-ui/tests/integration/timeline/echo.rs b/crates/matrix-sdk-ui/tests/integration/timeline/echo.rs index 4d5ea66a3..32529d36c 100644 --- a/crates/matrix-sdk-ui/tests/integration/timeline/echo.rs +++ b/crates/matrix-sdk-ui/tests/integration/timeline/echo.rs @@ -177,7 +177,8 @@ async fn retry_failed() { // After mocking the endpoint and retrying, it first transitions back out of // the error state - assert_next_matches!(timeline_stream, VectorDiff::Set { index: 0, value } => { + assert_next_matches!(timeline_stream, VectorDiff::Remove { index: 0 }); + assert_next_matches!(timeline_stream, VectorDiff::PushBack { value } => { assert_matches!(value.send_state(), Some(EventSendState::NotSentYet)); }); diff --git a/crates/matrix-sdk-ui/tests/integration/timeline/queue.rs b/crates/matrix-sdk-ui/tests/integration/timeline/queue.rs index c97648c47..ae1ca03b2 100644 --- a/crates/matrix-sdk-ui/tests/integration/timeline/queue.rs +++ b/crates/matrix-sdk-ui/tests/integration/timeline/queue.rs @@ -175,12 +175,15 @@ async fn retry_order() { timeline.retry_send("2".into()).await.unwrap(); timeline.retry_send("1".into()).await.unwrap(); - // Both items are immediately updated to indicate they are being sent - assert_next_matches!(timeline_stream, VectorDiff::Set { index: 1, value } => { + // Both items are immediately updated and moved to the bottom in the order + // of the function calls to indicate they are being sent + assert_next_matches!(timeline_stream, VectorDiff::Remove { index: 1 }); + assert_next_matches!(timeline_stream, VectorDiff::PushBack { value } => { assert_matches!(value.send_state().unwrap(), EventSendState::NotSentYet); assert_eq!(value.content().as_message().unwrap().body(), "Second."); }); - assert_next_matches!(timeline_stream, VectorDiff::Set { index: 0, value } => { + assert_next_matches!(timeline_stream, VectorDiff::Remove { index: 0 }); + assert_next_matches!(timeline_stream, VectorDiff::PushBack { value } => { assert_matches!(value.send_state().unwrap(), EventSendState::NotSentYet); assert_eq!(value.content().as_message().unwrap().body(), "First!"); }); @@ -188,14 +191,15 @@ async fn retry_order() { // Wait 200ms for the first msg, 100ms for the second, 300ms for overhead sleep(Duration::from_millis(600)).await; - // The second item should be updated first, since it was retried first - assert_next_matches!(timeline_stream, VectorDiff::Set { index: 1, value } => { + // The second item (now at index 0) should be updated first, since it was + // retried first + assert_next_matches!(timeline_stream, VectorDiff::Set { index: 0, value } => { assert_eq!(value.content().as_message().unwrap().body(), "Second."); assert_matches!(value.send_state().unwrap(), EventSendState::Sent { .. }); assert_eq!(value.event_id().unwrap(), "$5E2kLK/Sg342bgBU9ceEIEPYpbFaqJpZ"); }); // Then the first one - assert_next_matches!(timeline_stream, VectorDiff::Set { index: 0, value } => { + assert_next_matches!(timeline_stream, VectorDiff::Set { index: 1, value } => { assert_eq!(value.content().as_message().unwrap().body(), "First!"); assert_matches!(value.send_state().unwrap(), EventSendState::Sent { .. }); assert_eq!(value.event_id().unwrap(), "$PyHxV5mYzjetBUT3qZq7V95GOzxb02EP");