Use LiveToast instead of built-in flash helpers

So that they can stack and get dismissed automatically
This commit is contained in:
Claudio Ortolina
2025-07-16 15:26:30 +01:00
parent 41f040363e
commit acd34424f7
18 changed files with 64 additions and 61 deletions
+2
View File
@@ -47,6 +47,7 @@ defmodule MusicLibraryWeb do
use Gettext, backend: MusicLibraryWeb.Gettext use Gettext, backend: MusicLibraryWeb.Gettext
import LiveToast, only: [put_toast: 3]
import Plug.Conn import Plug.Conn
unquote(verified_routes()) unquote(verified_routes())
@@ -95,6 +96,7 @@ defmodule MusicLibraryWeb do
use Gettext, backend: MusicLibraryWeb.Gettext use Gettext, backend: MusicLibraryWeb.Gettext
use Fluxon use Fluxon
import LiveToast, only: [put_toast: 3]
# Core UI components and translation # Core UI components and translation
import MusicLibraryWeb.CoreComponents import MusicLibraryWeb.CoreComponents
# HTML escaping functionality # HTML escaping functionality
+3 -2
View File
@@ -1,7 +1,8 @@
defmodule MusicLibraryWeb.Auth do defmodule MusicLibraryWeb.Auth do
use Gettext, backend: MusicLibraryWeb.Gettext use Gettext, backend: MusicLibraryWeb.Gettext
import Phoenix.Controller, only: [put_flash: 3, redirect: 2] import LiveToast, only: [put_toast: 3]
import Phoenix.Controller, only: [redirect: 2]
import Plug.Conn import Plug.Conn
def correct_login_password?(password) do def correct_login_password?(password) do
@@ -35,7 +36,7 @@ defmodule MusicLibraryWeb.Auth do
conn conn
else else
conn conn
|> put_flash(:error, gettext("You must be logged in to access this page")) |> put_toast(:error, gettext("You must be logged in to access this page"))
|> redirect(to: "/login") |> redirect(to: "/login")
|> halt() |> halt()
end end
@@ -323,7 +323,7 @@ defmodule MusicLibraryWeb.BarcodeScannerComponent do
"Failed to search release for barcode #{number}: #{inspect(reason)}" "Failed to search release for barcode #{number}: #{inspect(reason)}"
end) end)
put_flash( put_toast(
socket, socket,
:error, :error,
gettext("Failed to search release for barcode %{number}", number: number) gettext("Failed to search release for barcode %{number}", number: number)
@@ -339,7 +339,7 @@ defmodule MusicLibraryWeb.BarcodeScannerComponent do
socket = socket =
case BarcodeScan.import_results(socket.assigns.scan_results, current_time) do case BarcodeScan.import_results(socket.assigns.scan_results, current_time) do
[] -> [] ->
put_flash(socket, :info, gettext("Records imported successfully")) put_toast(socket, :info, gettext("Records imported successfully"))
errors -> errors ->
errors_summary = errors_summary =
@@ -347,7 +347,7 @@ defmodule MusicLibraryWeb.BarcodeScannerComponent do
"#{number}: #{inspect(reason)}" "#{number}: #{inspect(reason)}"
end) end)
put_flash( put_toast(
socket, socket,
:error, :error,
gettext("Some records could not be imported: %{summary}", summary: errors_summary) gettext("Some records could not be imported: %{summary}", summary: errors_summary)
@@ -198,7 +198,7 @@ defmodule MusicLibraryWeb.FormComponent do
{:noreply, {:noreply,
socket socket
|> put_flash(:info, gettext("Record updated successfully")) |> put_toast(:info, gettext("Record updated successfully"))
|> push_patch(to: socket.assigns.patch)} |> push_patch(to: socket.assigns.patch)}
{:error, %Ecto.Changeset{} = changeset} -> {:error, %Ecto.Changeset{} = changeset} ->
@@ -147,12 +147,12 @@ defmodule MusicLibraryWeb.ReleaseComponent do
{:noreply, {:noreply,
socket socket
|> assign(:already_scrobbled, true) |> assign(:already_scrobbled, true)
|> put_flash(:info, gettext("Release scrobbled successfully"))} |> put_toast(:info, gettext("Release scrobbled successfully"))}
{:error, reason} -> {:error, reason} ->
{:noreply, {:noreply,
socket socket
|> put_flash( |> put_toast(
:error, :error,
gettext("Error scrobbling release") <> "," <> inspect(reason) gettext("Error scrobbling release") <> "," <> inspect(reason)
)} )}
@@ -177,12 +177,12 @@ defmodule MusicLibraryWeb.ReleaseComponent do
{:noreply, {:noreply,
socket socket
|> assign(:already_scrobbled, true) |> assign(:already_scrobbled, true)
|> put_flash(:info, gettext("Disc scrobbled successfully"))} |> put_toast(:info, gettext("Disc scrobbled successfully"))}
{:error, reason} -> {:error, reason} ->
{:noreply, {:noreply,
socket socket
|> put_flash( |> put_toast(
:error, :error,
gettext("Error scrobbling disc") <> "," <> inspect(reason) gettext("Error scrobbling disc") <> "," <> inspect(reason)
)} )}
@@ -7,12 +7,12 @@ defmodule MusicLibraryWeb.LastFmController do
with {:ok, session} <- LastFm.get_session(token), with {:ok, session} <- LastFm.get_session(token),
{:ok, _secret} <- Secrets.store("last_fm_session_key", session.key) do {:ok, _secret} <- Secrets.store("last_fm_session_key", session.key) do
conn conn
|> put_flash(:info, gettext("Successfully connected your Last.fm account")) |> put_toast(:info, gettext("Successfully connected your Last.fm account"))
|> redirect(to: ~p"/") |> redirect(to: ~p"/")
else else
{:error, reason} -> {:error, reason} ->
conn conn
|> put_flash(:error, "Failed to connect your Last.fm account: #{reason}") |> put_toast(:error, "Failed to connect your Last.fm account: #{reason}")
|> redirect(to: ~p"/") |> redirect(to: ~p"/")
end end
end end
@@ -22,7 +22,7 @@ defmodule MusicLibraryWeb.SessionController do
|> redirect(to: ~p"/") |> redirect(to: ~p"/")
else else
conn conn
|> put_flash(:error, gettext("Invalid password")) |> put_toast(:error, gettext("Invalid password"))
|> redirect(to: ~p"/login") |> redirect(to: ~p"/login")
end end
end end
+1 -1
View File
@@ -4,7 +4,7 @@ defmodule MusicLibraryWeb.Hooks.StaticAssets do
def on_mount(:default, _params, _session, socket) do def on_mount(:default, _params, _session, socket) do
socket = socket =
if static_changed?(socket) do if static_changed?(socket) do
put_flash(socket, :warning, gettext("The application has been updated, please reload.")) put_toast(socket, :warning, gettext("The application has been updated, please reload."))
else else
socket socket
end end
@@ -145,7 +145,7 @@ defmodule MusicLibraryWeb.ArtistLive.FormComponent do
{:noreply, {:noreply,
socket socket
|> put_flash(:info, gettext("Artist updated successfully")) |> put_toast(:info, gettext("Artist updated successfully"))
|> push_patch(to: socket.assigns.patch)} |> push_patch(to: socket.assigns.patch)}
{:error, %Ecto.Changeset{} = changeset} -> {:error, %Ecto.Changeset{} = changeset} ->
+10 -10
View File
@@ -108,13 +108,13 @@ defmodule MusicLibraryWeb.ArtistLive.Show do
{:ok, _record} -> {:ok, _record} ->
{:noreply, {:noreply,
socket socket
|> put_flash(:info, gettext("Record wishlisted successfully")) |> put_toast(:info, gettext("Record wishlisted successfully"))
|> push_patch(to: ~p"/artists/#{socket.assigns.artist.musicbrainz_id}")} |> push_patch(to: ~p"/artists/#{socket.assigns.artist.musicbrainz_id}")}
{:error, %Ecto.Changeset{} = changeset} -> {:error, %Ecto.Changeset{} = changeset} ->
{:noreply, {:noreply,
socket socket
|> put_flash( |> put_toast(
:error, :error,
gettext("Error wishlisting record") <> "," <> inspect(changeset.errors) gettext("Error wishlisting record") <> "," <> inspect(changeset.errors)
) )
@@ -123,7 +123,7 @@ defmodule MusicLibraryWeb.ArtistLive.Show do
{:error, reason} -> {:error, reason} ->
{:noreply, {:noreply,
socket socket
|> put_flash(:error, gettext("Error wishlisting record") <> "," <> inspect(reason)) |> put_toast(:error, gettext("Error wishlisting record") <> "," <> inspect(reason))
|> push_patch(to: ~p"/artists/#{socket.assigns.artist.musicbrainz_id}")} |> push_patch(to: ~p"/artists/#{socket.assigns.artist.musicbrainz_id}")}
end end
end end
@@ -134,12 +134,12 @@ defmodule MusicLibraryWeb.ArtistLive.Show do
{:noreply, {:noreply,
socket socket
|> assign(:artist_info, artist_info) |> assign(:artist_info, artist_info)
|> put_flash(:info, gettext("Artist info refreshed successfully"))} |> put_toast(:info, gettext("Artist info refreshed successfully"))}
{:error, reason} -> {:error, reason} ->
{:noreply, {:noreply,
socket socket
|> put_flash( |> put_toast(
:error, :error,
gettext("Error refreshing artist info") <> "," <> inspect(reason) gettext("Error refreshing artist info") <> "," <> inspect(reason)
)} )}
@@ -152,12 +152,12 @@ defmodule MusicLibraryWeb.ArtistLive.Show do
{:noreply, {:noreply,
socket socket
|> assign(:artist_info, artist_info) |> assign(:artist_info, artist_info)
|> put_flash(:info, gettext("Artist image refreshed successfully"))} |> put_toast(:info, gettext("Artist image refreshed successfully"))}
{:error, reason} -> {:error, reason} ->
{:noreply, {:noreply,
socket socket
|> put_flash( |> put_toast(
:error, :error,
gettext("Error refreshing artist image") <> "," <> inspect(reason) gettext("Error refreshing artist image") <> "," <> inspect(reason)
)} )}
@@ -173,12 +173,12 @@ defmodule MusicLibraryWeb.ArtistLive.Show do
{:noreply, {:noreply,
socket socket
|> assign_records(socket.assigns.artist.musicbrainz_id) |> assign_records(socket.assigns.artist.musicbrainz_id)
|> put_flash(:info, gettext("Record added to the collection"))} |> put_toast(:info, gettext("Record added to the collection"))}
{:error, %Ecto.Changeset{} = changeset} -> {:error, %Ecto.Changeset{} = changeset} ->
{:noreply, {:noreply,
socket socket
|> put_flash( |> put_toast(
:error, :error,
gettext("Error importing record") <> "," <> inspect(changeset.errors) gettext("Error importing record") <> "," <> inspect(changeset.errors)
)} )}
@@ -192,7 +192,7 @@ defmodule MusicLibraryWeb.ArtistLive.Show do
{:noreply, {:noreply,
socket socket
|> assign_records(socket.assigns.artist.musicbrainz_id) |> assign_records(socket.assigns.artist.musicbrainz_id)
|> put_flash(:info, gettext("Record deleted"))} |> put_toast(:info, gettext("Record deleted"))}
end end
defp apply_action(socket, :show, %{"musicbrainz_id" => musicbrainz_id}) do defp apply_action(socket, :show, %{"musicbrainz_id" => musicbrainz_id}) do
@@ -104,13 +104,13 @@ defmodule MusicLibraryWeb.CollectionLive.Index do
{:ok, record} -> {:ok, record} ->
{:noreply, {:noreply,
socket socket
|> put_flash(:info, gettext("Record imported successfully")) |> put_toast(:info, gettext("Record imported successfully"))
|> push_navigate(to: ~p"/collection/#{record.id}")} |> push_navigate(to: ~p"/collection/#{record.id}")}
{:error, %Ecto.Changeset{} = changeset} -> {:error, %Ecto.Changeset{} = changeset} ->
{:noreply, {:noreply,
socket socket
|> put_flash( |> put_toast(
:error, :error,
gettext("Error importing record") <> "," <> inspect(changeset.errors) gettext("Error importing record") <> "," <> inspect(changeset.errors)
) )
@@ -119,7 +119,7 @@ defmodule MusicLibraryWeb.CollectionLive.Index do
{:error, reason} -> {:error, reason} ->
{:noreply, {:noreply,
socket socket
|> put_flash(:error, gettext("Error importing record") <> "," <> inspect(reason)) |> put_toast(:error, gettext("Error importing record") <> "," <> inspect(reason))
|> push_patch(to: ~p"/collection")} |> push_patch(to: ~p"/collection")}
end end
end end
@@ -63,13 +63,13 @@ defmodule MusicLibraryWeb.CollectionLive.Show do
{:ok, updated_record} -> {:ok, updated_record} ->
{:noreply, {:noreply,
socket socket
|> put_flash(:info, gettext("MusicBrainz data refreshed successfully")) |> put_toast(:info, gettext("MusicBrainz data refreshed successfully"))
|> assign(:record, updated_record)} |> assign(:record, updated_record)}
{:error, reason} -> {:error, reason} ->
{:noreply, {:noreply,
socket socket
|> put_flash( |> put_toast(
:error, :error,
gettext("Error refreshing MusicBrainz data") <> "," <> inspect(reason) gettext("Error refreshing MusicBrainz data") <> "," <> inspect(reason)
)} )}
@@ -83,13 +83,13 @@ defmodule MusicLibraryWeb.CollectionLive.Show do
{:ok, updated_record} -> {:ok, updated_record} ->
{:noreply, {:noreply,
socket socket
|> put_flash(:info, gettext("Genres populated successfully")) |> put_toast(:info, gettext("Genres populated successfully"))
|> assign(:record, updated_record)} |> assign(:record, updated_record)}
{:error, reason} -> {:error, reason} ->
{:noreply, {:noreply,
socket socket
|> put_flash( |> put_toast(
:error, :error,
gettext("Error populating genres") <> "," <> inspect(reason) gettext("Error populating genres") <> "," <> inspect(reason)
)} )}
@@ -104,12 +104,12 @@ defmodule MusicLibraryWeb.CollectionLive.Show do
{:noreply, {:noreply,
socket socket
|> assign(:record, record) |> assign(:record, record)
|> put_flash(:info, gettext("Cover refreshed successfully"))} |> put_toast(:info, gettext("Cover refreshed successfully"))}
{:error, reason} -> {:error, reason} ->
{:noreply, {:noreply,
socket socket
|> put_flash( |> put_toast(
:error, :error,
gettext("Error refreshing cover") <> "," <> inspect(reason) gettext("Error refreshing cover") <> "," <> inspect(reason)
)} )}
@@ -124,12 +124,12 @@ defmodule MusicLibraryWeb.CollectionLive.Show do
{:ok, _worker} -> {:ok, _worker} ->
{:noreply, {:noreply,
socket socket
|> put_flash(:info, gettext("In progress - record will update automatically"))} |> put_toast(:info, gettext("In progress - record will update automatically"))}
{:error, reason} -> {:error, reason} ->
{:noreply, {:noreply,
socket socket
|> put_flash( |> put_toast(
:error, :error,
gettext("Error") <> "," <> inspect(reason) gettext("Error") <> "," <> inspect(reason)
)} )}
@@ -145,7 +145,7 @@ defmodule MusicLibraryWeb.CollectionLive.Show do
def handle_info({:update, record}, socket) do def handle_info({:update, record}, socket) do
{:noreply, {:noreply,
socket socket
|> put_flash(:info, gettext("Record updated in the background")) |> put_toast(:info, gettext("Record updated in the background"))
|> assign(:record, record)} |> assign(:record, record)}
end end
@@ -118,7 +118,7 @@ defmodule MusicLibraryWeb.OnlineStoreTemplateLive.FormComponent do
{:noreply, {:noreply,
socket socket
|> put_flash(:info, gettext("Online store template updated successfully")) |> put_toast(:info, gettext("Online store template updated successfully"))
|> push_patch(to: socket.assigns.patch)} |> push_patch(to: socket.assigns.patch)}
{:error, %Ecto.Changeset{} = changeset} -> {:error, %Ecto.Changeset{} = changeset} ->
@@ -133,7 +133,7 @@ defmodule MusicLibraryWeb.OnlineStoreTemplateLive.FormComponent do
{:noreply, {:noreply,
socket socket
|> put_flash(:info, gettext("Online store template created successfully")) |> put_toast(:info, gettext("Online store template created successfully"))
|> push_patch(to: socket.assigns.patch)} |> push_patch(to: socket.assigns.patch)}
{:error, %Ecto.Changeset{} = changeset} -> {:error, %Ecto.Changeset{} = changeset} ->
@@ -92,7 +92,7 @@ defmodule MusicLibraryWeb.ScrobbleRulesLive.FormComponent do
{:noreply, {:noreply,
socket socket
|> put_flash(:info, gettext("Scrobble rule updated successfully")) |> put_toast(:info, gettext("Scrobble rule updated successfully"))
|> push_patch(to: socket.assigns.patch)} |> push_patch(to: socket.assigns.patch)}
{:error, %Ecto.Changeset{} = changeset} -> {:error, %Ecto.Changeset{} = changeset} ->
@@ -107,7 +107,7 @@ defmodule MusicLibraryWeb.ScrobbleRulesLive.FormComponent do
{:noreply, {:noreply,
socket socket
|> put_flash(:info, gettext("Scrobble rule created successfully")) |> put_toast(:info, gettext("Scrobble rule created successfully"))
|> push_patch(to: socket.assigns.patch)} |> push_patch(to: socket.assigns.patch)}
{:error, %Ecto.Changeset{} = changeset} -> {:error, %Ecto.Changeset{} = changeset} ->
@@ -77,11 +77,11 @@ defmodule MusicLibraryWeb.ScrobbleRulesLive.Index do
case ScrobbleRules.apply_rule(scrobble_rule) do case ScrobbleRules.apply_rule(scrobble_rule) do
{:ok, count} -> {:ok, count} ->
message = gettext("Rule applied successfully. Updated %{count} tracks.", count: count) message = gettext("Rule applied successfully. Updated %{count} tracks.", count: count)
{:noreply, put_flash(socket, :info, message)} {:noreply, put_toast(socket, :info, message)}
{:error, reason} -> {:error, reason} ->
message = gettext("Error applying rule: %{reason}", reason: reason) message = gettext("Error applying rule: %{reason}", reason: reason)
{:noreply, put_flash(socket, :error, message)} {:noreply, put_toast(socket, :error, message)}
end end
end end
@@ -100,7 +100,7 @@ defmodule MusicLibraryWeb.ScrobbleRulesLive.Index do
count: total_updated count: total_updated
) )
{:noreply, put_flash(socket, :info, message)} {:noreply, put_toast(socket, :info, message)}
end end
attr :type, :atom, required: true, values: [:album, :artist] attr :type, :atom, required: true, values: [:album, :artist]
@@ -53,13 +53,13 @@ defmodule MusicLibraryWeb.StatsLive.Index do
{:ok, record} -> {:ok, record} ->
{:noreply, {:noreply,
socket socket
|> put_flash(:info, gettext("Record wishlisted successfully")) |> put_toast(:info, gettext("Record wishlisted successfully"))
|> push_navigate(to: ~p"/wishlist/#{record.id}")} |> push_navigate(to: ~p"/wishlist/#{record.id}")}
{:error, %Ecto.Changeset{} = changeset} -> {:error, %Ecto.Changeset{} = changeset} ->
{:noreply, {:noreply,
socket socket
|> put_flash( |> put_toast(
:error, :error,
gettext("Error wishlisting record") <> "," <> inspect(changeset.errors) gettext("Error wishlisting record") <> "," <> inspect(changeset.errors)
)} )}
@@ -67,7 +67,7 @@ defmodule MusicLibraryWeb.StatsLive.Index do
{:error, reason} -> {:error, reason} ->
{:noreply, {:noreply,
socket socket
|> put_flash(:error, gettext("Error wishlisting record") <> "," <> inspect(reason))} |> put_toast(:error, gettext("Error wishlisting record") <> "," <> inspect(reason))}
end end
end end
@@ -100,13 +100,13 @@ defmodule MusicLibraryWeb.WishlistLive.Index do
{:ok, record} -> {:ok, record} ->
{:noreply, {:noreply,
socket socket
|> put_flash(:info, gettext("Record wishlisted successfully")) |> put_toast(:info, gettext("Record wishlisted successfully"))
|> push_navigate(to: ~p"/wishlist/#{record.id}")} |> push_navigate(to: ~p"/wishlist/#{record.id}")}
{:error, %Ecto.Changeset{} = changeset} -> {:error, %Ecto.Changeset{} = changeset} ->
{:noreply, {:noreply,
socket socket
|> put_flash( |> put_toast(
:error, :error,
gettext("Error wishlisting record") <> "," <> inspect(changeset.errors) gettext("Error wishlisting record") <> "," <> inspect(changeset.errors)
) )
@@ -115,7 +115,7 @@ defmodule MusicLibraryWeb.WishlistLive.Index do
{:error, reason} -> {:error, reason} ->
{:noreply, {:noreply,
socket socket
|> put_flash(:error, gettext("Error wishlisting record") <> "," <> inspect(reason)) |> put_toast(:error, gettext("Error wishlisting record") <> "," <> inspect(reason))
|> push_patch(to: ~p"/wishlist")} |> push_patch(to: ~p"/wishlist")}
end end
end end
@@ -128,7 +128,7 @@ defmodule MusicLibraryWeb.WishlistLive.Index do
{:ok, _} -> {:ok, _} ->
{:noreply, {:noreply,
socket socket
|> put_flash(:info, gettext("Record added to the collection")) |> put_toast(:info, gettext("Record added to the collection"))
|> push_patch(to: ~p"/wishlist")} |> push_patch(to: ~p"/wishlist")}
{:error, %Ecto.Changeset{} = changeset} -> {:error, %Ecto.Changeset{} = changeset} ->
@@ -54,13 +54,13 @@ defmodule MusicLibraryWeb.WishlistLive.Show do
{:ok, updated_record} -> {:ok, updated_record} ->
{:noreply, {:noreply,
socket socket
|> put_flash(:info, gettext("MusicBrainz data refreshed successfully")) |> put_toast(:info, gettext("MusicBrainz data refreshed successfully"))
|> assign(:record, updated_record)} |> assign(:record, updated_record)}
{:error, reason} -> {:error, reason} ->
{:noreply, {:noreply,
socket socket
|> put_flash( |> put_toast(
:error, :error,
gettext("Error refreshing MusicBrainz data") <> "," <> inspect(reason) gettext("Error refreshing MusicBrainz data") <> "," <> inspect(reason)
)} )}
@@ -74,13 +74,13 @@ defmodule MusicLibraryWeb.WishlistLive.Show do
{:ok, updated_record} -> {:ok, updated_record} ->
{:noreply, {:noreply,
socket socket
|> put_flash(:info, gettext("Cover refreshed successfully")) |> put_toast(:info, gettext("Cover refreshed successfully"))
|> assign(:record, updated_record)} |> assign(:record, updated_record)}
{:error, reason} -> {:error, reason} ->
{:noreply, {:noreply,
socket socket
|> put_flash( |> put_toast(
:error, :error,
gettext("Error refreshing Cover") <> "," <> inspect(reason) gettext("Error refreshing Cover") <> "," <> inspect(reason)
)} )}
@@ -94,13 +94,13 @@ defmodule MusicLibraryWeb.WishlistLive.Show do
{:ok, updated_record} -> {:ok, updated_record} ->
{:noreply, {:noreply,
socket socket
|> put_flash(:info, gettext("Genres populated successfully")) |> put_toast(:info, gettext("Genres populated successfully"))
|> assign(:record, updated_record)} |> assign(:record, updated_record)}
{:error, reason} -> {:error, reason} ->
{:noreply, {:noreply,
socket socket
|> put_flash( |> put_toast(
:error, :error,
gettext("Error populating genres") <> "," <> inspect(reason) gettext("Error populating genres") <> "," <> inspect(reason)
)} )}
@@ -115,7 +115,7 @@ defmodule MusicLibraryWeb.WishlistLive.Show do
{:ok, _} -> {:ok, _} ->
{:noreply, {:noreply,
socket socket
|> put_flash(:info, gettext("Record added to the collection")) |> put_toast(:info, gettext("Record added to the collection"))
|> push_navigate(to: ~p"/wishlist")} |> push_navigate(to: ~p"/wishlist")}
{:error, %Ecto.Changeset{} = changeset} -> {:error, %Ecto.Changeset{} = changeset} ->
@@ -131,12 +131,12 @@ defmodule MusicLibraryWeb.WishlistLive.Show do
{:ok, _worker} -> {:ok, _worker} ->
{:noreply, {:noreply,
socket socket
|> put_flash(:info, gettext("In progress - record will update automatically"))} |> put_toast(:info, gettext("In progress - record will update automatically"))}
{:error, reason} -> {:error, reason} ->
{:noreply, {:noreply,
socket socket
|> put_flash( |> put_toast(
:error, :error,
gettext("Error") <> "," <> inspect(reason) gettext("Error") <> "," <> inspect(reason)
)} )}
@@ -152,7 +152,7 @@ defmodule MusicLibraryWeb.WishlistLive.Show do
def handle_info({:update, record}, socket) do def handle_info({:update, record}, socket) do
{:noreply, {:noreply,
socket socket
|> put_flash(:info, gettext("Record updated in the background")) |> put_toast(:info, gettext("Record updated in the background"))
|> assign(:record, record)} |> assign(:record, record)}
end end