refactor: restructure MessageInfo with logical field grouping (P2.6)
Сгруппированы 16 плоских полей MessageInfo в 4 логические структуры для улучшения организации кода и maintainability. Новые структуры: - MessageMetadata: id, sender_name, date, edit_date - MessageContent: text, entities - MessageState: is_outgoing, is_read, can_be_edited, can_be_deleted_* - MessageInteractions: reply_to, forward_from, reactions Изменения: - Добавлены 4 новые структуры в tdlib/types.rs - Обновлена MessageInfo для использования новых структур - Добавлен конструктор MessageInfo::new() для удобного создания - Добавлены getter методы (id(), text(), sender_name() и др.) для удобного доступа - Обновлены все места создания MessageInfo (convert_message) - Обновлены все места использования (~200+ обращений): * ui/messages.rs: рендеринг сообщений * app/mod.rs: логика приложения * input/main_input.rs: обработка ввода и копирование * tdlib/client.rs: обработка updates * Все тестовые файлы (14 файлов) Преимущества: - Логическая группировка данных - Проще понимать структуру сообщения - Легче добавлять новые поля в будущем - Улучшенная читаемость кода Статус: Priority 2 теперь 80% (4/5 задач) - ✅ Error enum - ✅ Config validation - ✅ Newtype для ID - ✅ MessageInfo реструктуризация - ⏳ MessageBuilder pattern Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -99,12 +99,12 @@ fn test_search_messages_in_chat() {
|
||||
let messages = client.get_messages(123);
|
||||
let found: Vec<_> = messages
|
||||
.iter()
|
||||
.filter(|m| m.content.to_lowercase().contains(&query))
|
||||
.filter(|m| m.text().to_lowercase().contains(&query))
|
||||
.collect();
|
||||
|
||||
assert_eq!(found.len(), 2);
|
||||
assert_eq!(found[0].content, "Hello world");
|
||||
assert_eq!(found[1].content, "Hello again");
|
||||
assert_eq!(found[0].text(), "Hello world");
|
||||
assert_eq!(found[1].text(), "Hello again");
|
||||
}
|
||||
|
||||
/// Test: Навигация по результатам поиска (n/N)
|
||||
@@ -124,7 +124,7 @@ fn test_navigate_search_results() {
|
||||
let results: Vec<_> = messages
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter(|(_, m)| m.content.to_lowercase().contains(&query))
|
||||
.filter(|(_, m)| m.text().to_lowercase().contains(&query))
|
||||
.collect();
|
||||
|
||||
assert_eq!(results.len(), 3);
|
||||
@@ -135,17 +135,17 @@ fn test_navigate_search_results() {
|
||||
// n - следующий результат
|
||||
current_index = (current_index + 1) % results.len();
|
||||
assert_eq!(current_index, 1);
|
||||
assert_eq!(results[current_index].1.content, "Second match");
|
||||
assert_eq!(results[current_index].1.text(), "Second match");
|
||||
|
||||
// n - ещё один
|
||||
current_index = (current_index + 1) % results.len();
|
||||
assert_eq!(current_index, 2);
|
||||
assert_eq!(results[current_index].1.content, "Third match");
|
||||
assert_eq!(results[current_index].1.text(), "Third match");
|
||||
|
||||
// n - wrap around к первому
|
||||
current_index = (current_index + 1) % results.len();
|
||||
assert_eq!(current_index, 0);
|
||||
assert_eq!(results[current_index].1.content, "First match");
|
||||
assert_eq!(results[current_index].1.text(), "First match");
|
||||
|
||||
// N - предыдущий (wrap to last)
|
||||
current_index = if current_index == 0 {
|
||||
@@ -154,7 +154,7 @@ fn test_navigate_search_results() {
|
||||
current_index - 1
|
||||
};
|
||||
assert_eq!(current_index, 2);
|
||||
assert_eq!(results[current_index].1.content, "Third match");
|
||||
assert_eq!(results[current_index].1.text(), "Third match");
|
||||
}
|
||||
|
||||
/// Test: Поиск с учётом регистра (case-insensitive)
|
||||
@@ -173,7 +173,7 @@ fn test_search_case_insensitive() {
|
||||
let messages = client.get_messages(123);
|
||||
let found: Vec<_> = messages
|
||||
.iter()
|
||||
.filter(|m| m.content.to_lowercase().contains(&query))
|
||||
.filter(|m| m.text().to_lowercase().contains(&query))
|
||||
.collect();
|
||||
|
||||
// Все 3 варианта должны найтись
|
||||
@@ -195,7 +195,7 @@ fn test_search_no_results() {
|
||||
let messages = client.get_messages(123);
|
||||
let found: Vec<_> = messages
|
||||
.iter()
|
||||
.filter(|m| m.content.to_lowercase().contains(&query))
|
||||
.filter(|m| m.text().to_lowercase().contains(&query))
|
||||
.collect();
|
||||
|
||||
assert_eq!(found.len(), 0);
|
||||
|
||||
Reference in New Issue
Block a user