fix: preserve reply_to info when editing messages

When editing a message that has a reply, convert_message() creates
a new ReplyInfo with sender_name="Unknown" and text="...". This was
causing the reply info to be lost after editing.

Solution: Save the old reply_to from the original message before
replacement, and restore it if the new message has "Unknown" reply info.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Mikhail Kilin
2026-02-01 00:31:38 +03:00
parent 426af96941
commit 326bf6cc46

View File

@@ -577,10 +577,19 @@ pub async fn handle(app: &mut App, key: KeyEvent) {
)
.await
{
Ok(Ok(edited_msg)) => {
// Заменяем сообщение целиком на отредактированное
Ok(Ok(mut edited_msg)) => {
// Сохраняем reply_to из старого сообщения (если есть)
let messages = app.td_client.current_chat_messages_mut();
if let Some(pos) = messages.iter().position(|m| m.id() == msg_id) {
let old_reply_to = messages[pos].interactions.reply_to.clone();
// Если в старом сообщении был reply и в новом он "Unknown" - сохраняем старый
if let Some(old_reply) = old_reply_to {
if edited_msg.interactions.reply_to.as_ref()
.map_or(true, |r| r.sender_name == "Unknown") {
edited_msg.interactions.reply_to = Some(old_reply);
}
}
// Заменяем сообщение
messages[pos] = edited_msg;
}
// Очищаем инпут и сбрасываем состояние ПОСЛЕ успешного редактирования