Fix inconsistent toast arity in form components

Closes #94
This commit is contained in:
Claudio Ortolina
2026-03-05 17:06:23 +00:00
parent 494996c4fb
commit 4b1f6bb245
5 changed files with 20 additions and 30 deletions
@@ -265,10 +265,11 @@ defmodule MusicLibraryWeb.ArtistLive.Form do
{:ok, artist_info} -> {:ok, artist_info} ->
notify_parent({:saved, artist_info}) notify_parent({:saved, artist_info})
put_toast!(:info, gettext("Artist image updated successfully"))
{:noreply, {:noreply,
socket socket
|> assign(:image_search_loading, false) |> assign(:image_search_loading, false)
|> put_toast(:info, gettext("Artist image updated successfully"))
|> push_patch(to: socket.assigns.patch)} |> push_patch(to: socket.assigns.patch)}
{:error, _changeset} -> {:error, _changeset} ->
@@ -298,16 +299,15 @@ defmodule MusicLibraryWeb.ArtistLive.Form do
{:ok, artist_info} <- Artists.update_artist_info(socket.assigns.artist_info, params) do {:ok, artist_info} <- Artists.update_artist_info(socket.assigns.artist_info, params) do
notify_parent({:saved, artist_info}) notify_parent({:saved, artist_info})
{:noreply, put_toast!(:info, gettext("Artist updated successfully"))
socket {:noreply, push_patch(socket, to: socket.assigns.patch)}
|> put_toast(:info, gettext("Artist updated successfully"))
|> push_patch(to: socket.assigns.patch)}
else else
{:error, %Ecto.Changeset{} = changeset} -> {:error, %Ecto.Changeset{} = changeset} ->
{:noreply, assign(socket, form: to_form(changeset))} {:noreply, assign(socket, form: to_form(changeset))}
{:error, _reason} -> {:error, _reason} ->
{:noreply, put_toast(socket, :error, gettext("Failed to store artist image"))} put_toast!(:error, gettext("Failed to store artist image"))
{:noreply, socket}
end end
end end
@@ -116,10 +116,8 @@ defmodule MusicLibraryWeb.OnlineStoreTemplateLive.Form do
{:ok, template} -> {:ok, template} ->
notify_parent({:saved, template}) notify_parent({:saved, template})
{:noreply, put_toast!(:info, gettext("Online store template updated successfully"))
socket {:noreply, push_patch(socket, to: socket.assigns.patch)}
|> put_toast(:info, gettext("Online store template updated successfully"))
|> push_patch(to: socket.assigns.patch)}
{:error, %Ecto.Changeset{} = changeset} -> {:error, %Ecto.Changeset{} = changeset} ->
{:noreply, assign(socket, form: to_form(changeset))} {:noreply, assign(socket, form: to_form(changeset))}
@@ -131,10 +129,8 @@ defmodule MusicLibraryWeb.OnlineStoreTemplateLive.Form do
{:ok, template} -> {:ok, template} ->
notify_parent({:saved, template}) notify_parent({:saved, template})
{:noreply, put_toast!(:info, gettext("Online store template created successfully"))
socket {:noreply, push_patch(socket, to: socket.assigns.patch)}
|> put_toast(:info, gettext("Online store template created successfully"))
|> push_patch(to: socket.assigns.patch)}
{:error, %Ecto.Changeset{} = changeset} -> {:error, %Ecto.Changeset{} = changeset} ->
{:noreply, assign(socket, form: to_form(changeset))} {:noreply, assign(socket, form: to_form(changeset))}
@@ -92,10 +92,8 @@ defmodule MusicLibraryWeb.ScrobbleRulesLive.Form do
{:ok, scrobble_rule} -> {:ok, scrobble_rule} ->
notify_parent({:updated, scrobble_rule}) notify_parent({:updated, scrobble_rule})
{:noreply, put_toast!(:info, gettext("Scrobble rule updated successfully"))
socket {:noreply, push_patch(socket, to: socket.assigns.patch)}
|> put_toast(:info, gettext("Scrobble rule updated successfully"))
|> push_patch(to: socket.assigns.patch)}
{:error, %Ecto.Changeset{} = changeset} -> {:error, %Ecto.Changeset{} = changeset} ->
{:noreply, assign(socket, form: to_form(changeset))} {:noreply, assign(socket, form: to_form(changeset))}
@@ -107,10 +105,8 @@ defmodule MusicLibraryWeb.ScrobbleRulesLive.Form do
{:ok, scrobble_rule} -> {:ok, scrobble_rule} ->
notify_parent({:created, scrobble_rule}) notify_parent({:created, scrobble_rule})
{:noreply, put_toast!(:info, gettext("Scrobble rule created successfully"))
socket {:noreply, push_patch(socket, to: socket.assigns.patch)}
|> put_toast(:info, gettext("Scrobble rule created successfully"))
|> push_patch(to: socket.assigns.patch)}
{:error, %Ecto.Changeset{} = changeset} -> {:error, %Ecto.Changeset{} = changeset} ->
{:noreply, assign(socket, form: to_form(changeset))} {:noreply, assign(socket, form: to_form(changeset))}
@@ -108,10 +108,8 @@ defmodule MusicLibraryWeb.ScrobbledTracksLive.Form do
{:ok, track} -> {:ok, track} ->
notify_parent({:saved, track}) notify_parent({:saved, track})
{:noreply, put_toast!(:info, gettext("Track updated successfully"))
socket {:noreply, push_patch(socket, to: socket.assigns.patch)}
|> put_toast(:info, gettext("Track updated successfully"))
|> push_patch(to: socket.assigns.patch)}
{:error, %Ecto.Changeset{} = changeset} -> {:error, %Ecto.Changeset{} = changeset} ->
{:noreply, assign(socket, form: to_form(changeset))} {:noreply, assign(socket, form: to_form(changeset))}
@@ -72,11 +72,11 @@ defmodule MusicLibraryWeb.ScrobbleRulesLiveTest do
|> form("#scrobble_rule-form", scrobble_rule: @invalid_attrs) |> form("#scrobble_rule-form", scrobble_rule: @invalid_attrs)
|> render_change() =~ "can&#39;t be blank" |> render_change() =~ "can&#39;t be blank"
html = index_live
index_live |> form("#scrobble_rule-form", scrobble_rule: @update_attrs)
|> form("#scrobble_rule-form", scrobble_rule: @update_attrs) |> render_submit()
|> render_submit()
html = render(index_live)
assert html =~ "Scrobble rule updated successfully" assert html =~ "Scrobble rule updated successfully"
assert html =~ "some updated match_value" assert html =~ "some updated match_value"
end end