Skip to content

Commit

Permalink
fix(ui): remove newlines from input values
Browse files Browse the repository at this point in the history
  • Loading branch information
ja-ko committed Jun 3, 2024
1 parent 42f25ac commit 0cd09ae
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/ui/voting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,24 @@ impl VotingPage {
}

pub fn confirm_input(&mut self, app: &mut App) -> AppResult<()> {
let buffer = self.input_buffer.as_ref().map(|b| b.trim().replace('\n', ""));
match self.input_mode {
InputMode::Vote if app.room.phase == GamePhase::Playing => {
if let Some(input_buffer) = &self.input_buffer {
if let Some(input_buffer) = &buffer {
let vote = input_buffer.clone();
app.vote(vote.as_str())?;
}
self.cancel_input();
}
InputMode::Name => {
if let Some(input_buffer) = &self.input_buffer {
if let Some(input_buffer) = &buffer {
let name = input_buffer.clone();
app.rename(name)?;
}
self.cancel_input();
}
InputMode::Chat => {
if let Some(input_buffer) = &self.input_buffer {
if let Some(input_buffer) = &buffer {
let name = input_buffer.clone();
app.chat(name)?;
}
Expand Down Expand Up @@ -422,7 +423,7 @@ impl Page for VotingPage {
self.cancel_input();
}

KeyCode::Char('\n') | KeyCode::Enter => {
KeyCode::Enter => {
self.confirm_input(app)?;
}

Expand Down

0 comments on commit 0cd09ae

Please sign in to comment.