add draft messages

This commit is contained in:
Mikhail Kilin
2026-01-27 12:31:31 +03:00
parent dc76e01f3c
commit ac684da820
5 changed files with 118 additions and 7 deletions

View File

@@ -257,6 +257,8 @@ pub async fn handle(app: &mut App, key: KeyEvent) {
let _ = timeout(Duration::from_secs(5), app.td_client.fetch_missing_reply_info()).await;
// Загружаем последнее закреплённое сообщение
let _ = timeout(Duration::from_secs(2), app.td_client.load_current_pinned_message(chat_id)).await;
// Загружаем черновик
app.load_draft();
app.status_message = None;
}
Ok(Err(e)) => {
@@ -386,6 +388,8 @@ pub async fn handle(app: &mut App, key: KeyEvent) {
let _ = timeout(Duration::from_secs(5), app.td_client.fetch_missing_reply_info()).await;
// Загружаем последнее закреплённое сообщение
let _ = timeout(Duration::from_secs(2), app.td_client.load_current_pinned_message(chat_id)).await;
// Загружаем черновик
app.load_draft();
app.status_message = None;
}
Ok(Err(e)) => {
@@ -415,6 +419,16 @@ pub async fn handle(app: &mut App, key: KeyEvent) {
// Отменить режим ответа
app.cancel_reply();
} else if app.selected_chat_id.is_some() {
// Сохраняем черновик если есть текст в инпуте
if let Some(chat_id) = app.selected_chat_id {
if !app.message_input.is_empty() && !app.is_editing() && !app.is_replying() {
let draft_text = app.message_input.clone();
let _ = app.td_client.set_draft_message(chat_id, draft_text).await;
} else if app.message_input.is_empty() {
// Очищаем черновик если инпут пустой
let _ = app.td_client.set_draft_message(chat_id, String::new()).await;
}
}
app.close_chat();
}
return;