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} ->
notify_parent({:saved, artist_info})
put_toast!(:info, gettext("Artist image updated successfully"))
{:noreply,
socket
|> assign(:image_search_loading, false)
|> put_toast(:info, gettext("Artist image updated successfully"))
|> push_patch(to: socket.assigns.patch)}
{:error, _changeset} ->
@@ -298,16 +299,15 @@ defmodule MusicLibraryWeb.ArtistLive.Form do
{:ok, artist_info} <- Artists.update_artist_info(socket.assigns.artist_info, params) do
notify_parent({:saved, artist_info})
{:noreply,
socket
|> put_toast(:info, gettext("Artist updated successfully"))
|> push_patch(to: socket.assigns.patch)}
put_toast!(:info, gettext("Artist updated successfully"))
{:noreply, push_patch(socket, to: socket.assigns.patch)}
else
{:error, %Ecto.Changeset{} = changeset} ->
{:noreply, assign(socket, form: to_form(changeset))}
{: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
@@ -116,10 +116,8 @@ defmodule MusicLibraryWeb.OnlineStoreTemplateLive.Form do
{:ok, template} ->
notify_parent({:saved, template})
{:noreply,
socket
|> put_toast(:info, gettext("Online store template updated successfully"))
|> push_patch(to: socket.assigns.patch)}
put_toast!(:info, gettext("Online store template updated successfully"))
{:noreply, push_patch(socket, to: socket.assigns.patch)}
{:error, %Ecto.Changeset{} = changeset} ->
{:noreply, assign(socket, form: to_form(changeset))}
@@ -131,10 +129,8 @@ defmodule MusicLibraryWeb.OnlineStoreTemplateLive.Form do
{:ok, template} ->
notify_parent({:saved, template})
{:noreply,
socket
|> put_toast(:info, gettext("Online store template created successfully"))
|> push_patch(to: socket.assigns.patch)}
put_toast!(:info, gettext("Online store template created successfully"))
{:noreply, push_patch(socket, to: socket.assigns.patch)}
{:error, %Ecto.Changeset{} = changeset} ->
{:noreply, assign(socket, form: to_form(changeset))}
@@ -92,10 +92,8 @@ defmodule MusicLibraryWeb.ScrobbleRulesLive.Form do
{:ok, scrobble_rule} ->
notify_parent({:updated, scrobble_rule})
{:noreply,
socket
|> put_toast(:info, gettext("Scrobble rule updated successfully"))
|> push_patch(to: socket.assigns.patch)}
put_toast!(:info, gettext("Scrobble rule updated successfully"))
{:noreply, push_patch(socket, to: socket.assigns.patch)}
{:error, %Ecto.Changeset{} = changeset} ->
{:noreply, assign(socket, form: to_form(changeset))}
@@ -107,10 +105,8 @@ defmodule MusicLibraryWeb.ScrobbleRulesLive.Form do
{:ok, scrobble_rule} ->
notify_parent({:created, scrobble_rule})
{:noreply,
socket
|> put_toast(:info, gettext("Scrobble rule created successfully"))
|> push_patch(to: socket.assigns.patch)}
put_toast!(:info, gettext("Scrobble rule created successfully"))
{:noreply, push_patch(socket, to: socket.assigns.patch)}
{:error, %Ecto.Changeset{} = changeset} ->
{:noreply, assign(socket, form: to_form(changeset))}
@@ -108,10 +108,8 @@ defmodule MusicLibraryWeb.ScrobbledTracksLive.Form do
{:ok, track} ->
notify_parent({:saved, track})
{:noreply,
socket
|> put_toast(:info, gettext("Track updated successfully"))
|> push_patch(to: socket.assigns.patch)}
put_toast!(:info, gettext("Track updated successfully"))
{:noreply, push_patch(socket, to: socket.assigns.patch)}
{:error, %Ecto.Changeset{} = changeset} ->
{:noreply, assign(socket, form: to_form(changeset))}
@@ -72,11 +72,11 @@ defmodule MusicLibraryWeb.ScrobbleRulesLiveTest do
|> form("#scrobble_rule-form", scrobble_rule: @invalid_attrs)
|> render_change() =~ "can&#39;t be blank"
html =
index_live
|> form("#scrobble_rule-form", scrobble_rule: @update_attrs)
|> render_submit()
html = render(index_live)
assert html =~ "Scrobble rule updated successfully"
assert html =~ "some updated match_value"
end