Refactored the connect flow and make canceling behavior more consistent.
This commit is contained in:
@@ -19,26 +19,27 @@ impl AddGamenight {
|
||||
#[async_trait]
|
||||
impl<'a> Flow<'a> for AddGamenight {
|
||||
async fn run(&self, state: &'a mut GamenightState) -> FlowResult<'a> {
|
||||
let mut add_gamenight = models::AddGamenightRequestBody::new();
|
||||
|
||||
add_gamenight.name = Some(Text::new("What should we call your gamenight")
|
||||
.prompt()?);
|
||||
let naive_date = DateSelect::new("When is your gamenight")
|
||||
.prompt()?;
|
||||
let naive_time = CustomType::<NaiveTime>::new("At What time")
|
||||
.prompt()?;
|
||||
add_gamenight.datetime = Some(naive_date
|
||||
.and_time(naive_time)
|
||||
.and_local_timezone(Local)
|
||||
.earliest()
|
||||
.unwrap()
|
||||
.to_utc()
|
||||
.to_rfc3339());
|
||||
|
||||
post_gamenight(&state.api_configuration, Some(add_gamenight)).await?;
|
||||
|
||||
clear_screen::clear();
|
||||
Ok((FlowOutcome::Successful, state))
|
||||
if let Some(name) = Text::new("What should we call your gamenight").prompt_skippable()? {
|
||||
if let Some(naive_date) = DateSelect::new("When is your gamenight").prompt_skippable()? {
|
||||
if let Some(naive_time) = CustomType::<NaiveTime>::new("At What time").prompt_skippable()? {
|
||||
|
||||
let datetime = naive_date
|
||||
.and_time(naive_time)
|
||||
.and_local_timezone(Local)
|
||||
.earliest()
|
||||
.unwrap()
|
||||
.to_utc()
|
||||
.to_rfc3339();
|
||||
let add_gamenight = models::AddGamenightRequestBody::new(name, datetime);
|
||||
post_gamenight(&state.api_configuration, Some(add_gamenight)).await?;
|
||||
|
||||
clear_screen::clear();
|
||||
return Ok((FlowOutcome::Successful, state))
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok((FlowOutcome::Cancelled, state))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user