refactor: integrate validation utils and complete refactoring #1

Завершена интеграция validation utils во всех местах проверки user input:

Changes:
- src/utils/mod.rs: раскомментирован экспорт validation::*
- src/input/auth.rs: 3 замены .is_empty() -> is_non_empty()
  * phone_input validation (line 18)
  * code_input validation (line 50)
  * password_input validation (line 82)
- src/input/main_input.rs: 1 замена для message_input (line 484)
- src/main.rs: заменён последний прямой timeout на with_timeout_ignore

Documentation:
- REFACTORING_OPPORTUNITIES.md: обновлён статус категории #1
  * Отмечено как "ПОЛНОСТЬЮ ЗАВЕРШЕНО" (2026-02-02)
  * Добавлены метрики: 100% покрытие retry utils, 0 прямых timeouts
  * Обновлён план выполнения: фаза 1 завершена
- CONTEXT.md: добавлен раздел об интеграции validation utils

Result:
 Категория #1 (Дублирование кода) - ПОЛНОСТЬЮ ЗАВЕРШЕНА!
  - retry utils: 100% покрытие (8+ мест)
  - modal_handler: 2 диалога
  - validation: 4 места

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Mikhail Kilin
2026-02-02 17:38:49 +03:00
parent 0768283e8a
commit 3c8fec7ca6
6 changed files with 88 additions and 24 deletions

View File

@@ -1,6 +1,6 @@
use crate::app::App;
use crate::tdlib::{AuthState, TdClientTrait};
use crate::utils::with_timeout_msg;
use crate::utils::{is_non_empty, with_timeout_msg};
use crossterm::event::KeyCode;
use std::time::Duration;
@@ -16,7 +16,7 @@ pub async fn handle<T: TdClientTrait>(app: &mut App<T>, key_code: KeyCode) {
app.error_message = None;
}
KeyCode::Enter => {
if !app.phone_input.is_empty() {
if is_non_empty(&app.phone_input) {
app.status_message = Some("Отправка номера...".to_string());
match with_timeout_msg(
Duration::from_secs(10),
@@ -48,7 +48,7 @@ pub async fn handle<T: TdClientTrait>(app: &mut App<T>, key_code: KeyCode) {
app.error_message = None;
}
KeyCode::Enter => {
if !app.code_input.is_empty() {
if is_non_empty(&app.code_input) {
app.status_message = Some("Проверка кода...".to_string());
match with_timeout_msg(
Duration::from_secs(10),
@@ -80,7 +80,7 @@ pub async fn handle<T: TdClientTrait>(app: &mut App<T>, key_code: KeyCode) {
app.error_message = None;
}
KeyCode::Enter => {
if !app.password_input.is_empty() {
if is_non_empty(&app.password_input) {
app.status_message = Some("Проверка пароля...".to_string());
match with_timeout_msg(
Duration::from_secs(10),

View File

@@ -6,7 +6,7 @@ use crate::input::handlers::{
};
use crate::tdlib::ChatAction;
use crate::types::{ChatId, MessageId};
use crate::utils::{with_timeout, with_timeout_msg, with_timeout_ignore};
use crate::utils::{is_non_empty, with_timeout, with_timeout_msg, with_timeout_ignore};
use crate::utils::modal_handler::handle_yes_no;
use crossterm::event::{KeyCode, KeyEvent, KeyModifiers};
use std::time::{Duration, Instant};
@@ -481,7 +481,7 @@ pub async fn handle<T: TdClientTrait>(app: &mut App<T>, key: KeyEvent) {
}
// Отправка или редактирование сообщения
if !app.message_input.is_empty() {
if is_non_empty(&app.message_input) {
if let Some(chat_id) = app.get_selected_chat_id() {
let text = app.message_input.clone();