refactor: cleanup unused code and warnings
Some checks failed
CI / Check (pull_request) Has been cancelled
CI / Format (pull_request) Has been cancelled
CI / Clippy (pull_request) Has been cancelled
CI / Build (macos-latest) (pull_request) Has been cancelled
CI / Build (ubuntu-latest) (pull_request) Has been cancelled
CI / Build (windows-latest) (pull_request) Has been cancelled
Some checks failed
CI / Check (pull_request) Has been cancelled
CI / Format (pull_request) Has been cancelled
CI / Clippy (pull_request) Has been cancelled
CI / Build (macos-latest) (pull_request) Has been cancelled
CI / Build (ubuntu-latest) (pull_request) Has been cancelled
CI / Build (windows-latest) (pull_request) Has been cancelled
Comprehensive cleanup of unused methods, dead code, and compiler warnings:
## Removed Methods (15):
- Duplicate delegation methods: is_authenticated, get_typing_text, get_user_name from TdClient
- Obsolete methods: TdClient::init() (duplicated in main.rs)
- Unused getters: UserCache::{get_username, get_name, get_user_id_by_chat}
- Unused builder methods: MessageBuilder::{edited, add_reaction}
- Unused utility: ChatState::is_normal()
- Dead code: HotkeysConfig::{matches, key_matches} (kept for tests)
- Unused method: UserCache::register_private_chat()
- Getter replaced with direct field access: MessageInfo::edit_date()
## Removed Module:
- error.rs - Unused error handling module (TeletuiError, ErrorVariant, IntoTeletuiError)
## Removed Constants (8):
- EMOJI_PICKER_COLUMNS, EMOJI_PICKER_ROWS, MAX_INPUT_HEIGHT
- MIN_TERMINAL_WIDTH, MIN_TERMINAL_HEIGHT
- TDLIB_CHAT_LIMIT, MAX_USERNAME_DISPLAY_LENGTH, MESSAGE_TEXT_INDENT
## Fixed Warnings:
- Removed unused imports (8 instances)
- Fixed unreachable patterns (10 instances)
- Fixed irrefutable if let patterns (2 instances)
- Fixed unused variables (1 instance)
- Removed dead_code annotations where appropriate
## Improvements:
- Integrated Config::load_credentials() into TdClient::new() for better credential management
- Replaced edit_date() getter with direct field access (message.metadata.edit_date)
- Updated tests to use direct field access instead of removed getters
## Test Results:
All tests passing: 499 passed, 0 failed
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -177,10 +177,10 @@ fn snapshot_chat_with_online_status() {
|
||||
// Устанавливаем онлайн-статус для чата напрямую
|
||||
let chat_id = ChatId::new(123);
|
||||
let user_id = tele_tui::types::UserId::new(123);
|
||||
|
||||
|
||||
// Регистрируем чат как приватный
|
||||
app.td_client.user_cache.register_private_chat(chat_id, user_id);
|
||||
|
||||
app.td_client.user_cache.chat_user_ids.insert(chat_id, user_id);
|
||||
|
||||
// Устанавливаем онлайн-статус
|
||||
app.td_client.user_cache.user_statuses.insert(user_id, UserOnlineStatus::Online);
|
||||
|
||||
|
||||
@@ -293,7 +293,7 @@ async fn test_user_journey_edit_during_conversation() {
|
||||
let edited_history = client.get_chat_history(ChatId::new(555), 50).await.unwrap();
|
||||
assert_eq!(edited_history.len(), 1);
|
||||
assert_eq!(edited_history[0].text(), "I'll be there at 5pm tomorrow");
|
||||
assert!(edited_history[0].edit_date() > 0, "Должна быть установлена дата редактирования");
|
||||
assert!(edited_history[0].metadata.edit_date > 0, "Должна быть установлена дата редактирования");
|
||||
|
||||
// 6. Проверяем историю редактирований
|
||||
assert_eq!(client.get_edited_messages().len(), 1);
|
||||
|
||||
@@ -39,15 +39,15 @@ async fn test_edit_message_sets_edit_date() {
|
||||
// Получаем дату до редактирования
|
||||
let messages_before = client.get_messages(123);
|
||||
let date_before = messages_before[0].date();
|
||||
assert_eq!(messages_before[0].edit_date(), 0); // Не редактировалось
|
||||
assert_eq!(messages_before[0].metadata.edit_date, 0); // Не редактировалось
|
||||
|
||||
// Редактируем сообщение
|
||||
client.edit_message(ChatId::new(123), msg.id(), "Edited".to_string()).await.unwrap();
|
||||
|
||||
// Проверяем что edit_date установлена
|
||||
let messages_after = client.get_messages(123);
|
||||
assert!(messages_after[0].edit_date() > 0);
|
||||
assert!(messages_after[0].edit_date() > date_before); // edit_date после date
|
||||
assert!(messages_after[0].metadata.edit_date > 0);
|
||||
assert!(messages_after[0].metadata.edit_date > date_before); // edit_date после date
|
||||
}
|
||||
|
||||
/// Test: Редактирование только своих сообщений (проверка через can_be_edited)
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use tele_tui::tdlib::{ChatInfo, FolderInfo, MessageInfo, NetworkState, ProfileInfo, ReplyInfo, ReactionInfo};
|
||||
use tele_tui::tdlib::{ChatInfo, MessageInfo, NetworkState, ProfileInfo, ReplyInfo};
|
||||
use tele_tui::tdlib::types::{FolderInfo, ReactionInfo};
|
||||
use tele_tui::types::{ChatId, MessageId, UserId};
|
||||
use tokio::sync::mpsc;
|
||||
|
||||
@@ -817,7 +818,7 @@ mod tests {
|
||||
let edited = client.get_edited_messages();
|
||||
assert_eq!(edited.len(), 1);
|
||||
assert_eq!(client.get_messages(123)[0].text(), "Hello World");
|
||||
assert!(client.get_messages(123)[0].edit_date() > 0);
|
||||
assert!(client.get_messages(123)[0].metadata.edit_date > 0);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Test data builders and fixtures
|
||||
|
||||
use tele_tui::tdlib::{ChatInfo, ForwardInfo, MessageInfo, ProfileInfo, ReactionInfo, ReplyInfo};
|
||||
use tele_tui::tdlib::{ChatInfo, MessageInfo, ProfileInfo, ReplyInfo};
|
||||
use tele_tui::tdlib::types::{ForwardInfo, ReactionInfo};
|
||||
use tele_tui::types::{ChatId, MessageId};
|
||||
|
||||
/// Builder для создания тестового чата
|
||||
@@ -176,7 +177,6 @@ impl TestMessageBuilder {
|
||||
pub fn forwarded_from(mut self, sender: &str) -> Self {
|
||||
self.forward_from = Some(ForwardInfo {
|
||||
sender_name: sender.to_string(),
|
||||
date: self.date - 3600,
|
||||
});
|
||||
self
|
||||
}
|
||||
|
||||
@@ -4,7 +4,8 @@ mod helpers;
|
||||
|
||||
use helpers::fake_tdclient::FakeTdClient;
|
||||
use helpers::test_data::TestMessageBuilder;
|
||||
use tele_tui::tdlib::{ForwardInfo, ReplyInfo};
|
||||
use tele_tui::tdlib::ReplyInfo;
|
||||
use tele_tui::tdlib::types::ForwardInfo;
|
||||
use tele_tui::types::{ChatId, MessageId};
|
||||
|
||||
/// Test: Reply создаёт сообщение с reply_to
|
||||
@@ -106,7 +107,6 @@ async fn test_forward_creates_message_with_forward_from() {
|
||||
|
||||
let forward = messages[0].forward_from().unwrap();
|
||||
assert_eq!(forward.sender_name, "Bob");
|
||||
assert!(forward.date > 0); // Дата установлена
|
||||
}
|
||||
|
||||
/// Test: Forward показывает "↪ Переслано от ..."
|
||||
|
||||
Reference in New Issue
Block a user