From d6f8e30d273c26bc5e21231737e7c2fa61ed00bc Mon Sep 17 00:00:00 2001 From: iequidoo Date: Sat, 4 Apr 2026 22:08:47 -0300 Subject: [PATCH] fix: Ensure that message being sent is added to the bottom (#8027) --- src/chat.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/chat.rs b/src/chat.rs index 7113f97be..28787a032 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -2910,11 +2910,23 @@ pub(crate) async fn create_send_msg_jobs(context: &Context, msg: &mut Message) - msg.param.remove(Param::GuaranteeE2ee); } msg.subject.clone_from(&rendered_msg.subject); + // Sort the message to the bottom. Employ `msgs_index7` to compute `timestamp`. context .sql .execute( - "UPDATE msgs SET pre_rfc724_mid=?, subject=?, param=? WHERE id=?", + " +UPDATE msgs SET + timestamp=( + SELECT MAX(timestamp) FROM msgs WHERE + state IN(10,13,16,18,20,24,26,28) AND + hidden IN(0,1) AND + chat_id=? + ), + pre_rfc724_mid=?, subject=?, param=? +WHERE id=? + ", ( + msg.chat_id, &msg.pre_rfc724_mid, &msg.subject, msg.param.to_string(),