commit
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
use crate::app::App;
|
||||
use crate::tdlib::client::AuthState;
|
||||
use crossterm::event::KeyCode;
|
||||
use std::time::Duration;
|
||||
use tokio::time::timeout;
|
||||
use crate::app::App;
|
||||
use crate::tdlib::client::AuthState;
|
||||
|
||||
pub async fn handle(app: &mut App, key_code: KeyCode) {
|
||||
match &app.td_client.auth_state {
|
||||
@@ -18,7 +18,12 @@ pub async fn handle(app: &mut App, key_code: KeyCode) {
|
||||
KeyCode::Enter => {
|
||||
if !app.phone_input.is_empty() {
|
||||
app.status_message = Some("Отправка номера...".to_string());
|
||||
match timeout(Duration::from_secs(10), app.td_client.send_phone_number(app.phone_input.clone())).await {
|
||||
match timeout(
|
||||
Duration::from_secs(10),
|
||||
app.td_client.send_phone_number(app.phone_input.clone()),
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(Ok(_)) => {
|
||||
app.error_message = None;
|
||||
app.status_message = None;
|
||||
@@ -48,7 +53,12 @@ pub async fn handle(app: &mut App, key_code: KeyCode) {
|
||||
KeyCode::Enter => {
|
||||
if !app.code_input.is_empty() {
|
||||
app.status_message = Some("Проверка кода...".to_string());
|
||||
match timeout(Duration::from_secs(10), app.td_client.send_code(app.code_input.clone())).await {
|
||||
match timeout(
|
||||
Duration::from_secs(10),
|
||||
app.td_client.send_code(app.code_input.clone()),
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(Ok(_)) => {
|
||||
app.error_message = None;
|
||||
app.status_message = None;
|
||||
@@ -78,7 +88,12 @@ pub async fn handle(app: &mut App, key_code: KeyCode) {
|
||||
KeyCode::Enter => {
|
||||
if !app.password_input.is_empty() {
|
||||
app.status_message = Some("Проверка пароля...".to_string());
|
||||
match timeout(Duration::from_secs(10), app.td_client.send_password(app.password_input.clone())).await {
|
||||
match timeout(
|
||||
Duration::from_secs(10),
|
||||
app.td_client.send_password(app.password_input.clone()),
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(Ok(_)) => {
|
||||
app.error_message = None;
|
||||
app.status_message = None;
|
||||
|
||||
Reference in New Issue
Block a user