Skip to content

Commit

Permalink
Reset guess letter form after submit in super hangman
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanppl committed Feb 9, 2025
1 parent 861b430 commit 35fb3f5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Set endpoint config URL to `playground.ethanppl.com`
- Handle error when player concurrently start/end games
- Fix Super tic tac toe: timer round off is incorrect
- Fix super tic tac toe: timer round off is incorrect
- Improvement in super hangman: reset guess letter form after submit

## [0.2.5] - 2024-12-15

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ defmodule PlaygroundWeb.GamesComponents.SuperHangmanComponent.GuessLetters do
changeset =
GuessLettersChangeset.changeset(
%GuessLettersChangeset{},
guess_letter_params
guess_letter_params |> IO.inspect(label: "guess_letter_params")

Check warning on line 531 in lib/playground_web/components/games_components/super_hangman/guess_letters.ex

View workflow job for this annotation

GitHub Actions / Test on OTP 26.2.3 / Elixir 1.16.2

There should be no calls to `IO.inspect/1`.
)

{:noreply, assign_letter_form(socket, Map.put(changeset, :action, :validate))}
Expand All @@ -540,14 +540,21 @@ defmodule PlaygroundWeb.GamesComponents.SuperHangmanComponent.GuessLetters do
|> GuessLettersChangeset.changeset(guess_letter_params)
|> Ecto.Changeset.apply_action(:insert)

changeset =
GuessLettersChangeset.changeset(
%GuessLettersChangeset{},
%{"letter" => ""}
)

case validation do
{:ok, _changeset} ->
notify_parent(
{:moved,
%{"type" => "letter", "letter" => String.upcase(guess_letter_params["letter"])}}
)

{:noreply, socket}
# Reset the form
{:noreply, assign_letter_form(socket, Map.put(changeset, :action, :validate))}

{:error, _changeset} ->
{:noreply, socket}
Expand Down

0 comments on commit 35fb3f5

Please sign in to comment.