diff --git a/lib/app_web/live/app_live.ex b/lib/app_web/live/app_live.ex index 0b9ac65d..0a41ceae 100644 --- a/lib/app_web/live/app_live.ex +++ b/lib/app_web/live/app_live.ex @@ -195,7 +195,6 @@ defmodule AppWeb.AppLive do end end - # Errors a specific changeset from a list of changesets and returns the updated list of changesets. # You should pass a: # - `timer_changeset_list: list of timer changesets to be updated @@ -203,28 +202,28 @@ defmodule AppWeb.AppLive do # - `changeset_index`: changeset object index inside the list of timer changesets # - `changeset_error_key`: atom key of the changeset object you want to associate the error message # - `changeset_error_message`: the string message to error the changeset key with. - @doc false - defp error_timer_changeset( - timer_changeset_list, + @doc false + defp error_timer_changeset( + timer_changeset_list, + changeset_to_error, + changeset_index, + changeset_error_key, + changeset_error_message + ) do + # Adding error to changeset + errored_changeset = + Ecto.Changeset.add_error( changeset_to_error, - changeset_index, changeset_error_key, changeset_error_message - ) do - # Adding error to changeset - errored_changeset = - Ecto.Changeset.add_error( - changeset_to_error, - changeset_error_key, - changeset_error_message - ) - - {_reply, errored_changeset} = - Ecto.Changeset.apply_action(errored_changeset, :update) - - # Updated list with errored changeset - List.replace_at(timer_changeset_list, changeset_index, errored_changeset) - end + ) + + {_reply, errored_changeset} = + Ecto.Changeset.apply_action(errored_changeset, :update) + + # Updated list with errored changeset + List.replace_at(timer_changeset_list, changeset_index, errored_changeset) + end @impl true def handle_info(%Broadcast{event: "update", payload: _message}, socket) do