fix: resolve all 40 clippy warnings (dead_code, unused_imports, lints)
Some checks failed
ci/woodpecker/pr/check Pipeline was successful
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/woodpecker/pr/check Pipeline was successful
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
- Add #[allow(unused_imports)] on pub re-exports used only by lib/tests - Add #[allow(dead_code)] on public API items unused in binary target - Fix collapsible_if, redundant_closure, unnecessary_map_or in main.rs - Prefix unused test variables with underscore Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -7,5 +7,7 @@
|
|||||||
pub mod manager;
|
pub mod manager;
|
||||||
pub mod profile;
|
pub mod profile;
|
||||||
|
|
||||||
|
#[allow(unused_imports)]
|
||||||
pub use manager::{add_account, ensure_account_dir, load_or_create, resolve_account, save};
|
pub use manager::{add_account, ensure_account_dir, load_or_create, resolve_account, save};
|
||||||
|
#[allow(unused_imports)]
|
||||||
pub use profile::{account_db_path, validate_account_name, AccountProfile, AccountsConfig};
|
pub use profile::{account_db_path, validate_account_name, AccountProfile, AccountsConfig};
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
use crate::tdlib::ChatInfo;
|
use crate::tdlib::ChatInfo;
|
||||||
|
|
||||||
/// Критерии фильтрации чатов
|
/// Критерии фильтрации чатов
|
||||||
|
#[allow(dead_code)]
|
||||||
#[derive(Debug, Clone, Default)]
|
#[derive(Debug, Clone, Default)]
|
||||||
pub struct ChatFilterCriteria {
|
pub struct ChatFilterCriteria {
|
||||||
/// Фильтр по папке (folder_id)
|
/// Фильтр по папке (folder_id)
|
||||||
@@ -33,6 +34,7 @@ pub struct ChatFilterCriteria {
|
|||||||
pub hide_archived: bool,
|
pub hide_archived: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
impl ChatFilterCriteria {
|
impl ChatFilterCriteria {
|
||||||
/// Создаёт критерии с дефолтными значениями
|
/// Создаёт критерии с дефолтными значениями
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
@@ -147,8 +149,10 @@ impl ChatFilterCriteria {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Централизованный фильтр чатов
|
/// Централизованный фильтр чатов
|
||||||
|
#[allow(dead_code)]
|
||||||
pub struct ChatFilter;
|
pub struct ChatFilter;
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
impl ChatFilter {
|
impl ChatFilter {
|
||||||
/// Фильтрует список чатов по критериям
|
/// Фильтрует список чатов по критериям
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -13,8 +13,13 @@ pub mod modal;
|
|||||||
pub mod navigation;
|
pub mod navigation;
|
||||||
pub mod search;
|
pub mod search;
|
||||||
|
|
||||||
|
#[allow(unused_imports)]
|
||||||
pub use compose::ComposeMethods;
|
pub use compose::ComposeMethods;
|
||||||
|
#[allow(unused_imports)]
|
||||||
pub use messages::MessageMethods;
|
pub use messages::MessageMethods;
|
||||||
|
#[allow(unused_imports)]
|
||||||
pub use modal::ModalMethods;
|
pub use modal::ModalMethods;
|
||||||
|
#[allow(unused_imports)]
|
||||||
pub use navigation::NavigationMethods;
|
pub use navigation::NavigationMethods;
|
||||||
|
#[allow(unused_imports)]
|
||||||
pub use search::SearchMethods;
|
pub use search::SearchMethods;
|
||||||
|
|||||||
@@ -51,9 +51,11 @@ pub trait SearchMethods<T: TdClientTrait> {
|
|||||||
fn update_search_query(&mut self, new_query: String);
|
fn update_search_query(&mut self, new_query: String);
|
||||||
|
|
||||||
/// Get index of selected search result
|
/// Get index of selected search result
|
||||||
|
#[allow(dead_code)]
|
||||||
fn get_search_selected_index(&self) -> Option<usize>;
|
fn get_search_selected_index(&self) -> Option<usize>;
|
||||||
|
|
||||||
/// Get all search results
|
/// Get all search results
|
||||||
|
#[allow(dead_code)]
|
||||||
fn get_search_results(&self) -> Option<&[MessageInfo]>;
|
fn get_search_results(&self) -> Option<&[MessageInfo]>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ mod state;
|
|||||||
|
|
||||||
pub use chat_filter::{ChatFilter, ChatFilterCriteria};
|
pub use chat_filter::{ChatFilter, ChatFilterCriteria};
|
||||||
pub use chat_state::{ChatState, InputMode};
|
pub use chat_state::{ChatState, InputMode};
|
||||||
|
#[allow(unused_imports)]
|
||||||
pub use methods::*;
|
pub use methods::*;
|
||||||
pub use state::AppScreen;
|
pub use state::AppScreen;
|
||||||
|
|
||||||
@@ -107,6 +108,7 @@ pub struct App<T: TdClientTrait = TdClient> {
|
|||||||
/// Время последней отправки typing status (для throttling)
|
/// Время последней отправки typing status (для throttling)
|
||||||
pub last_typing_sent: Option<std::time::Instant>,
|
pub last_typing_sent: Option<std::time::Instant>,
|
||||||
// Image support
|
// Image support
|
||||||
|
#[allow(dead_code)]
|
||||||
#[cfg(feature = "images")]
|
#[cfg(feature = "images")]
|
||||||
pub image_cache: Option<crate::media::cache::ImageCache>,
|
pub image_cache: Option<crate::media::cache::ImageCache>,
|
||||||
/// Renderer для inline preview в чате (Halfblocks - быстро)
|
/// Renderer для inline preview в чате (Halfblocks - быстро)
|
||||||
@@ -145,6 +147,7 @@ pub struct App<T: TdClientTrait = TdClient> {
|
|||||||
pub last_playback_tick: Option<std::time::Instant>,
|
pub last_playback_tick: Option<std::time::Instant>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
impl<T: TdClientTrait> App<T> {
|
impl<T: TdClientTrait> App<T> {
|
||||||
/// Creates a new App instance with the given configuration and client.
|
/// Creates a new App instance with the given configuration and client.
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ impl VoiceCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Clears all cached files
|
/// Clears all cached files
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn clear(&mut self) -> Result<(), String> {
|
pub fn clear(&mut self) -> Result<(), String> {
|
||||||
for (path, _, _) in self.files.values() {
|
for (path, _, _) in self.files.values() {
|
||||||
let _ = fs::remove_file(path); // Ignore errors
|
let _ = fs::remove_file(path); // Ignore errors
|
||||||
|
|||||||
@@ -139,11 +139,13 @@ impl AudioPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns true if a process is active (playing or paused)
|
/// Returns true if a process is active (playing or paused)
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn is_playing(&self) -> bool {
|
pub fn is_playing(&self) -> bool {
|
||||||
self.current_pid.lock().unwrap().is_some() && !*self.paused.lock().unwrap()
|
self.current_pid.lock().unwrap().is_some() && !*self.paused.lock().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns true if paused
|
/// Returns true if paused
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn is_paused(&self) -> bool {
|
pub fn is_paused(&self) -> bool {
|
||||||
self.current_pid.lock().unwrap().is_some() && *self.paused.lock().unwrap()
|
self.current_pid.lock().unwrap().is_some() && *self.paused.lock().unwrap()
|
||||||
}
|
}
|
||||||
@@ -153,13 +155,16 @@ impl AudioPlayer {
|
|||||||
self.current_pid.lock().unwrap().is_none() && !*self.starting.lock().unwrap()
|
self.current_pid.lock().unwrap().is_none() && !*self.starting.lock().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn set_volume(&self, _volume: f32) {}
|
pub fn set_volume(&self, _volume: f32) {}
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn adjust_volume(&self, _delta: f32) {}
|
pub fn adjust_volume(&self, _delta: f32) {}
|
||||||
|
|
||||||
pub fn volume(&self) -> f32 {
|
pub fn volume(&self) -> f32 {
|
||||||
1.0
|
1.0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn seek(&self, _delta: Duration) -> Result<(), String> {
|
pub fn seek(&self, _delta: Duration) -> Result<(), String> {
|
||||||
Err("Seeking not supported".to_string())
|
Err("Seeking not supported".to_string())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,10 +89,12 @@ impl KeyBinding {
|
|||||||
Self { key, modifiers: KeyModifiers::CONTROL }
|
Self { key, modifiers: KeyModifiers::CONTROL }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn with_shift(key: KeyCode) -> Self {
|
pub fn with_shift(key: KeyCode) -> Self {
|
||||||
Self { key, modifiers: KeyModifiers::SHIFT }
|
Self { key, modifiers: KeyModifiers::SHIFT }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn with_alt(key: KeyCode) -> Self {
|
pub fn with_alt(key: KeyCode) -> Self {
|
||||||
Self { key, modifiers: KeyModifiers::ALT }
|
Self { key, modifiers: KeyModifiers::ALT }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ pub const MAX_IMAGE_HEIGHT: u16 = 15;
|
|||||||
pub const MIN_IMAGE_HEIGHT: u16 = 3;
|
pub const MIN_IMAGE_HEIGHT: u16 = 3;
|
||||||
|
|
||||||
/// Таймаут скачивания файла (в секундах)
|
/// Таймаут скачивания файла (в секундах)
|
||||||
|
#[allow(dead_code)]
|
||||||
pub const FILE_DOWNLOAD_TIMEOUT_SECS: u64 = 30;
|
pub const FILE_DOWNLOAD_TIMEOUT_SECS: u64 = 30;
|
||||||
|
|
||||||
/// Размер кэша изображений по умолчанию (в МБ)
|
/// Размер кэша изображений по умолчанию (в МБ)
|
||||||
|
|||||||
@@ -37,11 +37,9 @@ fn parse_account_arg() -> Option<String> {
|
|||||||
let args: Vec<String> = std::env::args().collect();
|
let args: Vec<String> = std::env::args().collect();
|
||||||
let mut i = 1;
|
let mut i = 1;
|
||||||
while i < args.len() {
|
while i < args.len() {
|
||||||
if args[i] == "--account" {
|
if args[i] == "--account" && i + 1 < args.len() {
|
||||||
if i + 1 < args.len() {
|
|
||||||
return Some(args[i + 1].clone());
|
return Some(args[i + 1].clone());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
None
|
None
|
||||||
@@ -161,7 +159,7 @@ async fn run_app<B: ratatui::backend::Backend, T: tdlib::TdClientTrait>(
|
|||||||
let polling_handle = tokio::spawn(async move {
|
let polling_handle = tokio::spawn(async move {
|
||||||
while !should_stop_clone.load(Ordering::Relaxed) {
|
while !should_stop_clone.load(Ordering::Relaxed) {
|
||||||
// receive() с таймаутом 0.1 сек чтобы периодически проверять флаг
|
// receive() с таймаутом 0.1 сек чтобы периодически проверять флаг
|
||||||
let result = tokio::task::spawn_blocking(|| tdlib_rs::receive()).await;
|
let result = tokio::task::spawn_blocking(tdlib_rs::receive).await;
|
||||||
if let Ok(Some((update, _client_id))) = result {
|
if let Ok(Some((update, _client_id))) = result {
|
||||||
if update_tx.send(update).is_err() {
|
if update_tx.send(update).is_err() {
|
||||||
break; // Канал закрыт, выходим
|
break; // Канал закрыт, выходим
|
||||||
@@ -248,7 +246,7 @@ async fn run_app<B: ratatui::backend::Backend, T: tdlib::TdClientTrait>(
|
|||||||
|
|
||||||
// Проверяем завершение воспроизведения
|
// Проверяем завершение воспроизведения
|
||||||
if playback.position >= playback.duration
|
if playback.position >= playback.duration
|
||||||
|| app.audio_player.as_ref().map_or(false, |p| p.is_stopped())
|
|| app.audio_player.as_ref().is_some_and(|p| p.is_stopped())
|
||||||
{
|
{
|
||||||
stop_playback = true;
|
stop_playback = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,11 +6,13 @@ use std::fs;
|
|||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
/// Кэш изображений с LRU eviction по mtime
|
/// Кэш изображений с LRU eviction по mtime
|
||||||
|
#[allow(dead_code)]
|
||||||
pub struct ImageCache {
|
pub struct ImageCache {
|
||||||
cache_dir: PathBuf,
|
cache_dir: PathBuf,
|
||||||
max_size_bytes: u64,
|
max_size_bytes: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
impl ImageCache {
|
impl ImageCache {
|
||||||
/// Создаёт новый кэш с указанным лимитом в МБ
|
/// Создаёт новый кэш с указанным лимитом в МБ
|
||||||
pub fn new(cache_size_mb: u64) -> Self {
|
pub fn new(cache_size_mb: u64) -> Self {
|
||||||
@@ -89,6 +91,7 @@ impl ImageCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Обёртка для установки mtime без внешней зависимости
|
/// Обёртка для установки mtime без внешней зависимости
|
||||||
|
#[allow(dead_code)]
|
||||||
mod filetime {
|
mod filetime {
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
|
|||||||
@@ -108,6 +108,7 @@ impl ImageRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Удаляет протокол для сообщения
|
/// Удаляет протокол для сообщения
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn remove(&mut self, msg_id: &MessageId) {
|
pub fn remove(&mut self, msg_id: &MessageId) {
|
||||||
let msg_id_i64 = msg_id.as_i64();
|
let msg_id_i64 = msg_id.as_i64();
|
||||||
self.protocols.remove(&msg_id_i64);
|
self.protocols.remove(&msg_id_i64);
|
||||||
@@ -115,6 +116,7 @@ impl ImageRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Очищает все протоколы
|
/// Очищает все протоколы
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn clear(&mut self) {
|
pub fn clear(&mut self) {
|
||||||
self.protocols.clear();
|
self.protocols.clear();
|
||||||
self.access_order.clear();
|
self.access_order.clear();
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ use std::collections::HashSet;
|
|||||||
use notify_rust::{Notification, Timeout};
|
use notify_rust::{Notification, Timeout};
|
||||||
|
|
||||||
/// Manages desktop notifications
|
/// Manages desktop notifications
|
||||||
|
#[allow(dead_code)]
|
||||||
pub struct NotificationManager {
|
pub struct NotificationManager {
|
||||||
/// Whether notifications are enabled
|
/// Whether notifications are enabled
|
||||||
enabled: bool,
|
enabled: bool,
|
||||||
@@ -25,6 +26,7 @@ pub struct NotificationManager {
|
|||||||
urgency: String,
|
urgency: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
impl NotificationManager {
|
impl NotificationManager {
|
||||||
/// Creates a new notification manager with default settings
|
/// Creates a new notification manager with default settings
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ use tdlib_rs::functions;
|
|||||||
///
|
///
|
||||||
/// Отслеживает текущий этап аутентификации пользователя,
|
/// Отслеживает текущий этап аутентификации пользователя,
|
||||||
/// от инициализации TDLib до полной авторизации.
|
/// от инициализации TDLib до полной авторизации.
|
||||||
|
#[allow(dead_code)]
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
pub enum AuthState {
|
pub enum AuthState {
|
||||||
/// Ожидание параметров TDLib (начальное состояние).
|
/// Ожидание параметров TDLib (начальное состояние).
|
||||||
@@ -72,6 +73,7 @@ pub struct AuthManager {
|
|||||||
client_id: i32,
|
client_id: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
impl AuthManager {
|
impl AuthManager {
|
||||||
/// Создает новый менеджер авторизации.
|
/// Создает новый менеджер авторизации.
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -371,6 +371,7 @@ impl ChatManager {
|
|||||||
/// println!("Status: {}", typing_text);
|
/// println!("Status: {}", typing_text);
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn get_typing_text(&self) -> Option<String> {
|
pub fn get_typing_text(&self) -> Option<String> {
|
||||||
self.typing_status
|
self.typing_status
|
||||||
.as_ref()
|
.as_ref()
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ pub struct TdClient {
|
|||||||
pub network_state: NetworkState,
|
pub network_state: NetworkState,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
impl TdClient {
|
impl TdClient {
|
||||||
/// Creates a new TDLib client instance.
|
/// Creates a new TDLib client instance.
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ pub mod users;
|
|||||||
pub use auth::AuthState;
|
pub use auth::AuthState;
|
||||||
pub use client::TdClient;
|
pub use client::TdClient;
|
||||||
pub use r#trait::TdClientTrait;
|
pub use r#trait::TdClientTrait;
|
||||||
|
#[allow(unused_imports)]
|
||||||
pub use types::{
|
pub use types::{
|
||||||
ChatInfo, FolderInfo, MediaInfo, MessageBuilder, MessageInfo, NetworkState, PhotoDownloadState,
|
ChatInfo, FolderInfo, MediaInfo, MessageBuilder, MessageInfo, NetworkState, PhotoDownloadState,
|
||||||
PhotoInfo, PlaybackState, PlaybackStatus, ProfileInfo, ReplyInfo, UserOnlineStatus,
|
PhotoInfo, PlaybackState, PlaybackStatus, ProfileInfo, ReplyInfo, UserOnlineStatus,
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ use super::ChatInfo;
|
|||||||
///
|
///
|
||||||
/// This trait defines the interface for both real and fake TDLib clients,
|
/// This trait defines the interface for both real and fake TDLib clients,
|
||||||
/// enabling dependency injection and easier testing.
|
/// enabling dependency injection and easier testing.
|
||||||
|
#[allow(dead_code)]
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
pub trait TdClientTrait: Send {
|
pub trait TdClientTrait: Send {
|
||||||
// ============ Auth methods ============
|
// ============ Auth methods ============
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ pub struct PhotoInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Состояние загрузки фотографии
|
/// Состояние загрузки фотографии
|
||||||
|
#[allow(dead_code)]
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum PhotoDownloadState {
|
pub enum PhotoDownloadState {
|
||||||
NotDownloaded,
|
NotDownloaded,
|
||||||
@@ -80,6 +81,7 @@ pub enum PhotoDownloadState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Информация о голосовом сообщении
|
/// Информация о голосовом сообщении
|
||||||
|
#[allow(dead_code)]
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct VoiceInfo {
|
pub struct VoiceInfo {
|
||||||
pub file_id: i32,
|
pub file_id: i32,
|
||||||
@@ -91,6 +93,7 @@ pub struct VoiceInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Состояние загрузки голосового сообщения
|
/// Состояние загрузки голосового сообщения
|
||||||
|
#[allow(dead_code)]
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum VoiceDownloadState {
|
pub enum VoiceDownloadState {
|
||||||
NotDownloaded,
|
NotDownloaded,
|
||||||
@@ -283,6 +286,7 @@ impl MessageInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Возвращает мутабельную ссылку на VoiceInfo (если есть)
|
/// Возвращает мутабельную ссылку на VoiceInfo (если есть)
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn voice_info_mut(&mut self) -> Option<&mut VoiceInfo> {
|
pub fn voice_info_mut(&mut self) -> Option<&mut VoiceInfo> {
|
||||||
match &mut self.content.media {
|
match &mut self.content.media {
|
||||||
Some(MediaInfo::Voice(info)) => Some(info),
|
Some(MediaInfo::Voice(info)) => Some(info),
|
||||||
@@ -693,6 +697,7 @@ pub struct ImageModalState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Состояние воспроизведения голосового сообщения
|
/// Состояние воспроизведения голосового сообщения
|
||||||
|
#[allow(dead_code)]
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct PlaybackState {
|
pub struct PlaybackState {
|
||||||
/// ID сообщения, которое воспроизводится
|
/// ID сообщения, которое воспроизводится
|
||||||
@@ -708,6 +713,7 @@ pub struct PlaybackState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Статус воспроизведения
|
/// Статус воспроизведения
|
||||||
|
#[allow(dead_code)]
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
pub enum PlaybackStatus {
|
pub enum PlaybackStatus {
|
||||||
Playing,
|
Playing,
|
||||||
|
|||||||
@@ -213,6 +213,7 @@ impl UserCache {
|
|||||||
/// # Returns
|
/// # Returns
|
||||||
///
|
///
|
||||||
/// Имя пользователя (first_name + last_name) или "User {id}" если не найден.
|
/// Имя пользователя (first_name + last_name) или "User {id}" если не найден.
|
||||||
|
#[allow(dead_code)]
|
||||||
pub async fn get_user_name(&self, user_id: UserId) -> String {
|
pub async fn get_user_name(&self, user_id: UserId) -> String {
|
||||||
// Сначала пытаемся получить из кэша
|
// Сначала пытаемся получить из кэша
|
||||||
if let Some(name) = self.user_names.peek(&user_id) {
|
if let Some(name) = self.user_names.peek(&user_id) {
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ use tele_tui::tdlib::{ChatInfo, MessageInfo};
|
|||||||
use tele_tui::types::{ChatId, MessageId};
|
use tele_tui::types::{ChatId, MessageId};
|
||||||
|
|
||||||
/// Builder для создания тестового App с FakeTdClient\n///\n/// Использует trait-based DI для подмены TdClient на FakeTdClient в тестах.
|
/// Builder для создания тестового App с FakeTdClient\n///\n/// Использует trait-based DI для подмены TdClient на FakeTdClient в тестах.
|
||||||
|
#[allow(dead_code)]
|
||||||
pub struct TestAppBuilder {
|
pub struct TestAppBuilder {
|
||||||
config: Config,
|
config: Config,
|
||||||
screen: AppScreen,
|
screen: AppScreen,
|
||||||
@@ -34,6 +35,7 @@ impl Default for TestAppBuilder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
impl TestAppBuilder {
|
impl TestAppBuilder {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ use tokio::sync::mpsc;
|
|||||||
|
|
||||||
/// Update события от TDLib (упрощённая версия)
|
/// Update события от TDLib (упрощённая версия)
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
#[allow(dead_code)]
|
||||||
pub enum TdUpdate {
|
pub enum TdUpdate {
|
||||||
NewMessage {
|
NewMessage {
|
||||||
chat_id: ChatId,
|
chat_id: ChatId,
|
||||||
@@ -47,6 +48,7 @@ pub enum TdUpdate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Упрощённый mock TDLib клиента для тестов
|
/// Упрощённый mock TDLib клиента для тестов
|
||||||
|
#[allow(dead_code)]
|
||||||
pub struct FakeTdClient {
|
pub struct FakeTdClient {
|
||||||
// Данные
|
// Данные
|
||||||
pub chats: Arc<Mutex<Vec<ChatInfo>>>,
|
pub chats: Arc<Mutex<Vec<ChatInfo>>>,
|
||||||
@@ -86,6 +88,7 @@ pub struct FakeTdClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
#[allow(dead_code)]
|
||||||
pub struct SentMessage {
|
pub struct SentMessage {
|
||||||
pub chat_id: i64,
|
pub chat_id: i64,
|
||||||
pub text: String,
|
pub text: String,
|
||||||
@@ -94,6 +97,7 @@ pub struct SentMessage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
#[allow(dead_code)]
|
||||||
pub struct EditedMessage {
|
pub struct EditedMessage {
|
||||||
pub chat_id: i64,
|
pub chat_id: i64,
|
||||||
pub message_id: MessageId,
|
pub message_id: MessageId,
|
||||||
@@ -101,6 +105,7 @@ pub struct EditedMessage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
#[allow(dead_code)]
|
||||||
pub struct DeletedMessages {
|
pub struct DeletedMessages {
|
||||||
pub chat_id: i64,
|
pub chat_id: i64,
|
||||||
pub message_ids: Vec<MessageId>,
|
pub message_ids: Vec<MessageId>,
|
||||||
@@ -108,6 +113,7 @@ pub struct DeletedMessages {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
#[allow(dead_code)]
|
||||||
pub struct ForwardedMessages {
|
pub struct ForwardedMessages {
|
||||||
pub from_chat_id: i64,
|
pub from_chat_id: i64,
|
||||||
pub to_chat_id: i64,
|
pub to_chat_id: i64,
|
||||||
@@ -115,6 +121,7 @@ pub struct ForwardedMessages {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
#[allow(dead_code)]
|
||||||
pub struct SearchQuery {
|
pub struct SearchQuery {
|
||||||
pub chat_id: i64,
|
pub chat_id: i64,
|
||||||
pub query: String,
|
pub query: String,
|
||||||
@@ -158,6 +165,7 @@ impl Clone for FakeTdClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
impl FakeTdClient {
|
impl FakeTdClient {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ use tele_tui::tdlib::{ChatInfo, MessageInfo, ProfileInfo, ReplyInfo};
|
|||||||
use tele_tui::types::{ChatId, MessageId};
|
use tele_tui::types::{ChatId, MessageId};
|
||||||
|
|
||||||
/// Builder для создания тестового чата
|
/// Builder для создания тестового чата
|
||||||
|
#[allow(dead_code)]
|
||||||
pub struct TestChatBuilder {
|
pub struct TestChatBuilder {
|
||||||
id: i64,
|
id: i64,
|
||||||
title: String,
|
title: String,
|
||||||
@@ -21,6 +22,7 @@ pub struct TestChatBuilder {
|
|||||||
draft_text: Option<String>,
|
draft_text: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
impl TestChatBuilder {
|
impl TestChatBuilder {
|
||||||
pub fn new(title: &str, id: i64) -> Self {
|
pub fn new(title: &str, id: i64) -> Self {
|
||||||
Self {
|
Self {
|
||||||
@@ -100,6 +102,7 @@ impl TestChatBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Builder для создания тестового сообщения
|
/// Builder для создания тестового сообщения
|
||||||
|
#[allow(dead_code)]
|
||||||
pub struct TestMessageBuilder {
|
pub struct TestMessageBuilder {
|
||||||
id: i64,
|
id: i64,
|
||||||
sender_name: String,
|
sender_name: String,
|
||||||
@@ -118,6 +121,7 @@ pub struct TestMessageBuilder {
|
|||||||
media_album_id: i64,
|
media_album_id: i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
impl TestMessageBuilder {
|
impl TestMessageBuilder {
|
||||||
pub fn new(content: &str, id: i64) -> Self {
|
pub fn new(content: &str, id: i64) -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ async fn test_enter_opens_chat() {
|
|||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_esc_closes_chat() {
|
async fn test_esc_closes_chat() {
|
||||||
// Состояние: открыт чат 123
|
// Состояние: открыт чат 123
|
||||||
let selected_chat_id = Some(123);
|
let _selected_chat_id = Some(123);
|
||||||
|
|
||||||
// Пользователь нажал Esc
|
// Пользователь нажал Esc
|
||||||
let selected_chat_id: Option<i64> = None;
|
let selected_chat_id: Option<i64> = None;
|
||||||
@@ -97,7 +97,7 @@ async fn test_scroll_messages_in_chat() {
|
|||||||
|
|
||||||
let client = client.with_messages(123, messages);
|
let client = client.with_messages(123, messages);
|
||||||
|
|
||||||
let msgs = client.get_messages(123);
|
let _msgs = client.get_messages(123);
|
||||||
|
|
||||||
// Скролл начинается снизу (последнее сообщение видно)
|
// Скролл начинается снизу (последнее сообщение видно)
|
||||||
let mut scroll_offset: usize = 0;
|
let mut scroll_offset: usize = 0;
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ async fn test_typing_indicator_off() {
|
|||||||
/// Test: Отправка своего typing status
|
/// Test: Отправка своего typing status
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_send_own_typing_status() {
|
async fn test_send_own_typing_status() {
|
||||||
let client = FakeTdClient::new();
|
let _client = FakeTdClient::new();
|
||||||
|
|
||||||
// Пользователь начал печатать в чате 456
|
// Пользователь начал печатать в чате 456
|
||||||
// В реальном App вызывается client.send_chat_action(chat_id, ChatAction::Typing)
|
// В реальном App вызывается client.send_chat_action(chat_id, ChatAction::Typing)
|
||||||
|
|||||||
Reference in New Issue
Block a user