mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-15 19:45:34 -04:00
ui: Move echoes to the bottom immediately when retrying
This commit is contained in:
committed by
Jonas Platte
parent
9dc6ac45d2
commit
0daf3aeb6b
@@ -697,7 +697,8 @@ impl<P: RoomDataProvider> TimelineInner<P> {
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
});
|
||||
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user