fixes
This commit is contained in:
18
src/main.rs
18
src/main.rs
@@ -109,12 +109,22 @@ async fn run_app<B: ratatui::backend::Backend>(
|
||||
app.td_client.process_pending_view_messages().await;
|
||||
}
|
||||
|
||||
// Обрабатываем очередь user_id для загрузки имён
|
||||
if !app.td_client.pending_user_ids.is_empty() {
|
||||
app.td_client.process_pending_user_ids().await;
|
||||
}
|
||||
|
||||
// Синхронизируем сообщения из td_client в app (для новых сообщений в реальном времени)
|
||||
if app.selected_chat_id.is_some() && !app.td_client.current_chat_messages.is_empty() {
|
||||
// Добавляем новые сообщения, которых ещё нет в app.current_messages
|
||||
for msg in &app.td_client.current_chat_messages {
|
||||
if !app.current_messages.iter().any(|m| m.id == msg.id) {
|
||||
app.current_messages.push(msg.clone());
|
||||
// Синхронизируем все сообщения (включая обновлённые имена и is_read)
|
||||
for td_msg in &app.td_client.current_chat_messages {
|
||||
if let Some(app_msg) = app.current_messages.iter_mut().find(|m| m.id == td_msg.id) {
|
||||
// Обновляем существующее сообщение
|
||||
app_msg.sender_name = td_msg.sender_name.clone();
|
||||
app_msg.is_read = td_msg.is_read;
|
||||
} else {
|
||||
// Добавляем новое сообщение
|
||||
app.current_messages.push(td_msg.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user