Split up get_account_name into 2 states: get_new_name and get_existing_name

This commit is contained in:
2023-06-04 18:46:59 +03:00
parent cc41fbbaa4
commit 3b2633c880
11 changed files with 161 additions and 138 deletions

View File

@ -1,6 +1,6 @@
use crate::{
errors::NoUserInfo, markups::deletion_markup, models::DecryptedAccount, state::NameCheckKind,
Handler, MainDialogue, State,
errors::NoUserInfo, markups::deletion_markup, models::DecryptedAccount, Handler, MainDialogue,
State,
};
use sea_orm::prelude::*;
use teloxide::{adaptors::Throttle, prelude::*};
@ -101,10 +101,7 @@ pub async fn add_account(
) -> crate::Result<()> {
let previous = bot.send_message(msg.chat.id, "Send account name").await?;
dialogue
.update(State::GetAccountName(
Handler::new(get_account_name, previous),
NameCheckKind::NewAccountName,
))
.update(State::GetNewName(Handler::new(get_account_name, previous)))
.await?;
Ok(())
}

View File

@ -1,7 +1,6 @@
use crate::{
errors::NoUserInfo,
markups::{self, deletion_markup},
state::NameCheckKind,
Handler, MainDialogue, State,
};
use entity::prelude::*;
@ -60,10 +59,10 @@ pub async fn delete(
.reply_markup(markup)
.await?;
dialogue
.update(State::GetAccountName(
Handler::new(get_account_name, previous),
NameCheckKind::MustExist,
))
.update(State::GetExistingName(Handler::new(
get_account_name,
previous,
)))
.await?;
Ok(())
}

View File

@ -1,7 +1,6 @@
use crate::{
errors::NoUserInfo,
markups::{self, deletion_markup},
state::NameCheckKind,
Handler, MainDialogue, State,
};
use cryptography::prelude::*;
@ -75,10 +74,10 @@ pub async fn get_account(
.reply_markup(markup)
.await?;
dialogue
.update(State::GetAccountName(
Handler::new(get_account_name, previous),
NameCheckKind::MustExist,
))
.update(State::GetExistingName(Handler::new(
get_account_name,
previous,
)))
.await?;
Ok(())
}