Skip to content

Commit d6f8e30

Browse files
committed
fix: Ensure that message being sent is added to the bottom (#8027)
1 parent d839777 commit d6f8e30

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

src/chat.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2910,11 +2910,23 @@ pub(crate) async fn create_send_msg_jobs(context: &Context, msg: &mut Message) -
29102910
msg.param.remove(Param::GuaranteeE2ee);
29112911
}
29122912
msg.subject.clone_from(&rendered_msg.subject);
2913+
// Sort the message to the bottom. Employ `msgs_index7` to compute `timestamp`.
29132914
context
29142915
.sql
29152916
.execute(
2916-
"UPDATE msgs SET pre_rfc724_mid=?, subject=?, param=? WHERE id=?",
2917+
"
2918+
UPDATE msgs SET
2919+
timestamp=(
2920+
SELECT MAX(timestamp) FROM msgs WHERE
2921+
state IN(10,13,16,18,20,24,26,28) AND
2922+
hidden IN(0,1) AND
2923+
chat_id=?
2924+
),
2925+
pre_rfc724_mid=?, subject=?, param=?
2926+
WHERE id=?
2927+
",
29172928
(
2929+
msg.chat_id,
29182930
&msg.pre_rfc724_mid,
29192931
&msg.subject,
29202932
msg.param.to_string(),

0 commit comments

Comments
 (0)