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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user