refactor: encapsulate auth fields (Group 1/5)
Фаза 1, Подход 2 - постепенная инкапсуляция полей App. Changes: - src/app/mod.rs: сделаны приватными phone_input, code_input, password_input - src/input/auth.rs: замены на phone_input_mut(), code_input_mut(), password_input_mut() - src/ui/auth.rs: замены на phone_input(), code_input(), password_input() - tests/helpers/app_builder.rs: замены на set_phone_input(), set_code_input(), set_password_input() Используются существующие геттеры/сеттеры (были добавлены ранее). Progress: Group 1/5 complete (auth fields) Next: Group 2 (UI state: screen, is_loading, needs_redraw, is_searching) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -8,19 +8,19 @@ pub async fn handle<T: TdClientTrait>(app: &mut App<T>, key_code: KeyCode) {
|
||||
match &app.td_client.auth_state() {
|
||||
AuthState::WaitPhoneNumber => match key_code {
|
||||
KeyCode::Char(c) => {
|
||||
app.phone_input.push(c);
|
||||
app.phone_input_mut().push(c);
|
||||
app.error_message = None;
|
||||
}
|
||||
KeyCode::Backspace => {
|
||||
app.phone_input.pop();
|
||||
app.phone_input_mut().pop();
|
||||
app.error_message = None;
|
||||
}
|
||||
KeyCode::Enter => {
|
||||
if is_non_empty(&app.phone_input) {
|
||||
if is_non_empty(app.phone_input()) {
|
||||
app.status_message = Some("Отправка номера...".to_string());
|
||||
match with_timeout_msg(
|
||||
Duration::from_secs(10),
|
||||
app.td_client.send_phone_number(app.phone_input.clone()),
|
||||
app.td_client.send_phone_number(app.phone_input().to_string()),
|
||||
"Таймаут отправки номера",
|
||||
)
|
||||
.await
|
||||
@@ -40,19 +40,19 @@ pub async fn handle<T: TdClientTrait>(app: &mut App<T>, key_code: KeyCode) {
|
||||
},
|
||||
AuthState::WaitCode => match key_code {
|
||||
KeyCode::Char(c) if c.is_numeric() => {
|
||||
app.code_input.push(c);
|
||||
app.code_input_mut().push(c);
|
||||
app.error_message = None;
|
||||
}
|
||||
KeyCode::Backspace => {
|
||||
app.code_input.pop();
|
||||
app.code_input_mut().pop();
|
||||
app.error_message = None;
|
||||
}
|
||||
KeyCode::Enter => {
|
||||
if is_non_empty(&app.code_input) {
|
||||
if is_non_empty(app.code_input()) {
|
||||
app.status_message = Some("Проверка кода...".to_string());
|
||||
match with_timeout_msg(
|
||||
Duration::from_secs(10),
|
||||
app.td_client.send_code(app.code_input.clone()),
|
||||
app.td_client.send_code(app.code_input().to_string()),
|
||||
"Таймаут проверки кода",
|
||||
)
|
||||
.await
|
||||
@@ -72,19 +72,19 @@ pub async fn handle<T: TdClientTrait>(app: &mut App<T>, key_code: KeyCode) {
|
||||
},
|
||||
AuthState::WaitPassword => match key_code {
|
||||
KeyCode::Char(c) => {
|
||||
app.password_input.push(c);
|
||||
app.password_input_mut().push(c);
|
||||
app.error_message = None;
|
||||
}
|
||||
KeyCode::Backspace => {
|
||||
app.password_input.pop();
|
||||
app.password_input_mut().pop();
|
||||
app.error_message = None;
|
||||
}
|
||||
KeyCode::Enter => {
|
||||
if is_non_empty(&app.password_input) {
|
||||
if is_non_empty(app.password_input()) {
|
||||
app.status_message = Some("Проверка пароля...".to_string());
|
||||
match with_timeout_msg(
|
||||
Duration::from_secs(10),
|
||||
app.td_client.send_password(app.password_input.clone()),
|
||||
app.td_client.send_password(app.password_input().to_string()),
|
||||
"Таймаут проверки пароля",
|
||||
)
|
||||
.await
|
||||
|
||||
Reference in New Issue
Block a user