fix: update UI after editing message

Issue: Message edits worked on server (other users saw changes),
but local UI didn't update - edited text wasn't visible.

Root cause: Code was updating individual fields instead of replacing
the whole message, and wasn't triggering UI redraw.

Solution:
- Replace entire message with edited_msg (not individual fields)
- Set needs_redraw = true to trigger UI update
- Remove debug logging

Now edited messages immediately appear in local UI.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Mikhail Kilin
2026-02-01 00:16:47 +03:00
parent fe924faff4
commit 0ae8a2fb88
2 changed files with 10 additions and 23 deletions

View File

@@ -578,21 +578,16 @@ pub async fn handle(app: &mut App, key: KeyEvent) {
.await
{
Ok(Ok(edited_msg)) => {
// Обновляем сообщение в списке
if let Some(msg) = app
.td_client
.current_chat_messages_mut()
.iter_mut()
.find(|m| m.id() == msg_id)
{
msg.content.text = edited_msg.content.text;
msg.content.entities = edited_msg.content.entities;
msg.metadata.edit_date = edited_msg.metadata.edit_date;
// Заменяем сообщение целиком на отредактированное
let messages = app.td_client.current_chat_messages_mut();
if let Some(pos) = messages.iter().position(|m| m.id() == msg_id) {
messages[pos] = edited_msg;
}
// Очищаем инпут и сбрасываем состояние ПОСЛЕ успешного редактирования
app.message_input.clear();
app.cursor_position = 0;
app.chat_state = crate::app::ChatState::Normal;
app.needs_redraw = true; // ВАЖНО: перерисовываем UI
}
Ok(Err(e)) => {
app.error_message = Some(e);