fix: handle UpdateMessageSendSucceeded to prevent edit errors
Fixes "Message not found" error when editing immediately after sending. **Problem**: When sending a message, TDLib may return a temporary ID, then send UpdateMessageSendSucceeded with the real server ID. We weren't handling this update, so the cache kept the old ID while the server had a different one, causing "Message not found" errors during edits. **Solution**: 1. Added UpdateMessageSendSucceeded handler (client.rs:801-830) - Finds message with temporary ID - Replaces it with new message containing real server ID - Preserves reply_info if present 2. Added validation before editing (main_input.rs:574-589) - Checks message exists in cache - Better error messages with chat_id and message_id 3. Added positive ID check in start_editing_selected (mod.rs:240) - Blocks editing messages with temporary IDs (negative) **Test**: - Added test_edit_immediately_after_send (edit_message.rs:156-181) - Verifies editing works right after send_message - All 22 edit_message tests pass Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -234,7 +234,11 @@ impl App {
|
||||
|
||||
// Сначала извлекаем данные из сообщения
|
||||
let msg_data = self.get_selected_message().and_then(|msg| {
|
||||
if msg.can_be_edited() && msg.is_outgoing() {
|
||||
// Проверяем:
|
||||
// 1. Можно редактировать
|
||||
// 2. Это исходящее сообщение
|
||||
// 3. ID не временный (временные ID в TDLib отрицательные)
|
||||
if msg.can_be_edited() && msg.is_outgoing() && msg.id().as_i64() > 0 {
|
||||
Some((msg.id(), msg.text().to_string(), selected_idx.unwrap()))
|
||||
} else {
|
||||
None
|
||||
|
||||
Reference in New Issue
Block a user