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:
@@ -577,10 +577,19 @@ pub async fn handle(app: &mut App, key: KeyEvent) {
|
|||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
Ok(Ok(edited_msg)) => {
|
Ok(Ok(mut edited_msg)) => {
|
||||||
// Заменяем сообщение целиком на отредактированное
|
// Сохраняем reply_to из старого сообщения (если есть)
|
||||||
let messages = app.td_client.current_chat_messages_mut();
|
let messages = app.td_client.current_chat_messages_mut();
|
||||||
if let Some(pos) = messages.iter().position(|m| m.id() == msg_id) {
|
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;
|
messages[pos] = edited_msg;
|
||||||
}
|
}
|
||||||
// Очищаем инпут и сбрасываем состояние ПОСЛЕ успешного редактирования
|
// Очищаем инпут и сбрасываем состояние ПОСЛЕ успешного редактирования
|
||||||
|
|||||||
Reference in New Issue
Block a user