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

@@ -517,4 +517,24 @@ impl App {
pub fn get_selected_search_result_id(&self) -> Option<i64> {
self.get_selected_search_result().map(|m| m.id)
}
// === Draft Management ===
/// Получить черновик для текущего чата
pub fn get_current_draft(&self) -> Option<String> {
self.selected_chat_id.and_then(|chat_id| {
self.chats
.iter()
.find(|c| c.id == chat_id)
.and_then(|c| c.draft_text.clone())
})
}
/// Загрузить черновик в message_input (вызывается при открытии чата)
pub fn load_draft(&mut self) {
if let Some(draft) = self.get_current_draft() {
self.message_input = draft;
self.cursor_position = self.message_input.chars().count();
}
}
}