From c8075e53d22c6ec12e6438ec2320773d0095c884 Mon Sep 17 00:00:00 2001 From: iequidoo Date: Sat, 6 Jan 2024 21:59:17 -0300 Subject: [PATCH] fix: Reset message error when scheduling resending (#5119) Before, while a message is in OutPending state after resending is requested, the user still sees the red marker with error and it is confusing, so the user don't know the sending state of the message. --- src/message.rs | 3 ++- src/receive_imf/tests.rs | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/message.rs b/src/message.rs index 166e2d8fc..2711c5bf5 100644 --- a/src/message.rs +++ b/src/message.rs @@ -1663,7 +1663,8 @@ pub(crate) async fn update_msg_state( msg_id: MsgId, state: MessageState, ) -> Result<()> { - let error_subst = match state >= MessageState::OutDelivered { + ensure!(state != MessageState::OutFailed, "use set_msg_failed()!"); + let error_subst = match state >= MessageState::OutPending { true => ", error=''", false => "", }; diff --git a/src/receive_imf/tests.rs b/src/receive_imf/tests.rs index c7004211f..6a561ef5c 100644 --- a/src/receive_imf/tests.rs +++ b/src/receive_imf/tests.rs @@ -689,6 +689,9 @@ async fn test_resend_after_ndn() -> Result<()> { ) .await; chat::resend_msgs(&t, &[msg_id]).await?; + let msg = Message::load_from_db(&t, msg_id).await?; + assert_eq!(msg.state, MessageState::OutPending); + assert_eq!(msg.error(), None); // Alice receives a BCC-self copy of their message. receive_imf( &t,