ui: Move echoes to the bottom immediately when retrying

This commit is contained in:
Jonas Platte
2023-07-11 15:56:16 +02:00
committed by Jonas Platte
parent 9dc6ac45d2
commit 0daf3aeb6b
3 changed files with 14 additions and 8 deletions

View File

@@ -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)
}

View File

@@ -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));
});

View File

@@ -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");