This commit is contained in:
Mikhail Kilin
2026-01-30 16:18:16 +03:00
parent 4deb0fbe00
commit a4cf6bac72
9 changed files with 936 additions and 215 deletions

View File

@@ -1,5 +1,6 @@
mod app;
mod config;
mod constants;
mod input;
mod tdlib;
mod ui;
@@ -18,6 +19,7 @@ use std::time::Duration;
use tdlib_rs::enums::Update;
use app::{App, AppScreen};
use constants::{POLL_TIMEOUT_MS, SHUTDOWN_TIMEOUT_SECS};
use input::{handle_auth_input, handle_main_input};
use tdlib::client::AuthState;
use utils::disable_tdlib_logs;
@@ -148,7 +150,7 @@ async fn run_app<B: ratatui::backend::Backend>(
// Используем poll с коротким таймаутом для быстрой реакции на ввод
// 16ms ≈ 60 FPS потенциально, но рендерим только при изменениях
if event::poll(Duration::from_millis(16))? {
if event::poll(Duration::from_millis(POLL_TIMEOUT_MS))? {
match event::read()? {
Event::Key(key) => {
// Global quit command
@@ -162,7 +164,7 @@ async fn run_app<B: ratatui::backend::Backend>(
let _ = tdlib_rs::functions::close(app.td_client.client_id()).await;
// Ждём завершения polling задачи (с таймаутом)
let _ = tokio::time::timeout(Duration::from_secs(2), polling_handle).await;
let _ = tokio::time::timeout(Duration::from_secs(SHUTDOWN_TIMEOUT_SECS), polling_handle).await;
return Ok(());
}