Use LiveToast instead of built-in flash helpers
So that they can stack and get dismissed automatically
This commit is contained in:
@@ -145,7 +145,7 @@ defmodule MusicLibraryWeb.ArtistLive.FormComponent do
|
||||
|
||||
{:noreply,
|
||||
socket
|
||||
|> put_flash(:info, gettext("Artist updated successfully"))
|
||||
|> put_toast(:info, gettext("Artist updated successfully"))
|
||||
|> push_patch(to: socket.assigns.patch)}
|
||||
|
||||
{:error, %Ecto.Changeset{} = changeset} ->
|
||||
|
||||
@@ -108,13 +108,13 @@ defmodule MusicLibraryWeb.ArtistLive.Show do
|
||||
{:ok, _record} ->
|
||||
{:noreply,
|
||||
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}")}
|
||||
|
||||
{:error, %Ecto.Changeset{} = changeset} ->
|
||||
{:noreply,
|
||||
socket
|
||||
|> put_flash(
|
||||
|> put_toast(
|
||||
:error,
|
||||
gettext("Error wishlisting record") <> "," <> inspect(changeset.errors)
|
||||
)
|
||||
@@ -123,7 +123,7 @@ defmodule MusicLibraryWeb.ArtistLive.Show do
|
||||
{:error, reason} ->
|
||||
{:noreply,
|
||||
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}")}
|
||||
end
|
||||
end
|
||||
@@ -134,12 +134,12 @@ defmodule MusicLibraryWeb.ArtistLive.Show do
|
||||
{:noreply,
|
||||
socket
|
||||
|> assign(:artist_info, artist_info)
|
||||
|> put_flash(:info, gettext("Artist info refreshed successfully"))}
|
||||
|> put_toast(:info, gettext("Artist info refreshed successfully"))}
|
||||
|
||||
{:error, reason} ->
|
||||
{:noreply,
|
||||
socket
|
||||
|> put_flash(
|
||||
|> put_toast(
|
||||
:error,
|
||||
gettext("Error refreshing artist info") <> "," <> inspect(reason)
|
||||
)}
|
||||
@@ -152,12 +152,12 @@ defmodule MusicLibraryWeb.ArtistLive.Show do
|
||||
{:noreply,
|
||||
socket
|
||||
|> assign(:artist_info, artist_info)
|
||||
|> put_flash(:info, gettext("Artist image refreshed successfully"))}
|
||||
|> put_toast(:info, gettext("Artist image refreshed successfully"))}
|
||||
|
||||
{:error, reason} ->
|
||||
{:noreply,
|
||||
socket
|
||||
|> put_flash(
|
||||
|> put_toast(
|
||||
:error,
|
||||
gettext("Error refreshing artist image") <> "," <> inspect(reason)
|
||||
)}
|
||||
@@ -173,12 +173,12 @@ defmodule MusicLibraryWeb.ArtistLive.Show do
|
||||
{:noreply,
|
||||
socket
|
||||
|> 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} ->
|
||||
{:noreply,
|
||||
socket
|
||||
|> put_flash(
|
||||
|> put_toast(
|
||||
:error,
|
||||
gettext("Error importing record") <> "," <> inspect(changeset.errors)
|
||||
)}
|
||||
@@ -192,7 +192,7 @@ defmodule MusicLibraryWeb.ArtistLive.Show do
|
||||
{:noreply,
|
||||
socket
|
||||
|> assign_records(socket.assigns.artist.musicbrainz_id)
|
||||
|> put_flash(:info, gettext("Record deleted"))}
|
||||
|> put_toast(:info, gettext("Record deleted"))}
|
||||
end
|
||||
|
||||
defp apply_action(socket, :show, %{"musicbrainz_id" => musicbrainz_id}) do
|
||||
|
||||
@@ -104,13 +104,13 @@ defmodule MusicLibraryWeb.CollectionLive.Index do
|
||||
{:ok, record} ->
|
||||
{:noreply,
|
||||
socket
|
||||
|> put_flash(:info, gettext("Record imported successfully"))
|
||||
|> put_toast(:info, gettext("Record imported successfully"))
|
||||
|> push_navigate(to: ~p"/collection/#{record.id}")}
|
||||
|
||||
{:error, %Ecto.Changeset{} = changeset} ->
|
||||
{:noreply,
|
||||
socket
|
||||
|> put_flash(
|
||||
|> put_toast(
|
||||
:error,
|
||||
gettext("Error importing record") <> "," <> inspect(changeset.errors)
|
||||
)
|
||||
@@ -119,7 +119,7 @@ defmodule MusicLibraryWeb.CollectionLive.Index do
|
||||
{:error, reason} ->
|
||||
{:noreply,
|
||||
socket
|
||||
|> put_flash(:error, gettext("Error importing record") <> "," <> inspect(reason))
|
||||
|> put_toast(:error, gettext("Error importing record") <> "," <> inspect(reason))
|
||||
|> push_patch(to: ~p"/collection")}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -63,13 +63,13 @@ defmodule MusicLibraryWeb.CollectionLive.Show do
|
||||
{:ok, updated_record} ->
|
||||
{:noreply,
|
||||
socket
|
||||
|> put_flash(:info, gettext("MusicBrainz data refreshed successfully"))
|
||||
|> put_toast(:info, gettext("MusicBrainz data refreshed successfully"))
|
||||
|> assign(:record, updated_record)}
|
||||
|
||||
{:error, reason} ->
|
||||
{:noreply,
|
||||
socket
|
||||
|> put_flash(
|
||||
|> put_toast(
|
||||
:error,
|
||||
gettext("Error refreshing MusicBrainz data") <> "," <> inspect(reason)
|
||||
)}
|
||||
@@ -83,13 +83,13 @@ defmodule MusicLibraryWeb.CollectionLive.Show do
|
||||
{:ok, updated_record} ->
|
||||
{:noreply,
|
||||
socket
|
||||
|> put_flash(:info, gettext("Genres populated successfully"))
|
||||
|> put_toast(:info, gettext("Genres populated successfully"))
|
||||
|> assign(:record, updated_record)}
|
||||
|
||||
{:error, reason} ->
|
||||
{:noreply,
|
||||
socket
|
||||
|> put_flash(
|
||||
|> put_toast(
|
||||
:error,
|
||||
gettext("Error populating genres") <> "," <> inspect(reason)
|
||||
)}
|
||||
@@ -104,12 +104,12 @@ defmodule MusicLibraryWeb.CollectionLive.Show do
|
||||
{:noreply,
|
||||
socket
|
||||
|> assign(:record, record)
|
||||
|> put_flash(:info, gettext("Cover refreshed successfully"))}
|
||||
|> put_toast(:info, gettext("Cover refreshed successfully"))}
|
||||
|
||||
{:error, reason} ->
|
||||
{:noreply,
|
||||
socket
|
||||
|> put_flash(
|
||||
|> put_toast(
|
||||
:error,
|
||||
gettext("Error refreshing cover") <> "," <> inspect(reason)
|
||||
)}
|
||||
@@ -124,12 +124,12 @@ defmodule MusicLibraryWeb.CollectionLive.Show do
|
||||
{:ok, _worker} ->
|
||||
{:noreply,
|
||||
socket
|
||||
|> put_flash(:info, gettext("In progress - record will update automatically"))}
|
||||
|> put_toast(:info, gettext("In progress - record will update automatically"))}
|
||||
|
||||
{:error, reason} ->
|
||||
{:noreply,
|
||||
socket
|
||||
|> put_flash(
|
||||
|> put_toast(
|
||||
:error,
|
||||
gettext("Error") <> "," <> inspect(reason)
|
||||
)}
|
||||
@@ -145,7 +145,7 @@ defmodule MusicLibraryWeb.CollectionLive.Show do
|
||||
def handle_info({:update, record}, socket) do
|
||||
{:noreply,
|
||||
socket
|
||||
|> put_flash(:info, gettext("Record updated in the background"))
|
||||
|> put_toast(:info, gettext("Record updated in the background"))
|
||||
|> assign(:record, record)}
|
||||
end
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@ defmodule MusicLibraryWeb.OnlineStoreTemplateLive.FormComponent do
|
||||
|
||||
{:noreply,
|
||||
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)}
|
||||
|
||||
{:error, %Ecto.Changeset{} = changeset} ->
|
||||
@@ -133,7 +133,7 @@ defmodule MusicLibraryWeb.OnlineStoreTemplateLive.FormComponent do
|
||||
|
||||
{:noreply,
|
||||
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)}
|
||||
|
||||
{:error, %Ecto.Changeset{} = changeset} ->
|
||||
|
||||
@@ -92,7 +92,7 @@ defmodule MusicLibraryWeb.ScrobbleRulesLive.FormComponent do
|
||||
|
||||
{:noreply,
|
||||
socket
|
||||
|> put_flash(:info, gettext("Scrobble rule updated successfully"))
|
||||
|> put_toast(:info, gettext("Scrobble rule updated successfully"))
|
||||
|> push_patch(to: socket.assigns.patch)}
|
||||
|
||||
{:error, %Ecto.Changeset{} = changeset} ->
|
||||
@@ -107,7 +107,7 @@ defmodule MusicLibraryWeb.ScrobbleRulesLive.FormComponent do
|
||||
|
||||
{:noreply,
|
||||
socket
|
||||
|> put_flash(:info, gettext("Scrobble rule created successfully"))
|
||||
|> put_toast(:info, gettext("Scrobble rule created successfully"))
|
||||
|> push_patch(to: socket.assigns.patch)}
|
||||
|
||||
{:error, %Ecto.Changeset{} = changeset} ->
|
||||
|
||||
@@ -77,11 +77,11 @@ defmodule MusicLibraryWeb.ScrobbleRulesLive.Index do
|
||||
case ScrobbleRules.apply_rule(scrobble_rule) do
|
||||
{:ok, 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} ->
|
||||
message = gettext("Error applying rule: %{reason}", reason: reason)
|
||||
{:noreply, put_flash(socket, :error, message)}
|
||||
{:noreply, put_toast(socket, :error, message)}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -100,7 +100,7 @@ defmodule MusicLibraryWeb.ScrobbleRulesLive.Index do
|
||||
count: total_updated
|
||||
)
|
||||
|
||||
{:noreply, put_flash(socket, :info, message)}
|
||||
{:noreply, put_toast(socket, :info, message)}
|
||||
end
|
||||
|
||||
attr :type, :atom, required: true, values: [:album, :artist]
|
||||
|
||||
@@ -53,13 +53,13 @@ defmodule MusicLibraryWeb.StatsLive.Index do
|
||||
{:ok, record} ->
|
||||
{:noreply,
|
||||
socket
|
||||
|> put_flash(:info, gettext("Record wishlisted successfully"))
|
||||
|> put_toast(:info, gettext("Record wishlisted successfully"))
|
||||
|> push_navigate(to: ~p"/wishlist/#{record.id}")}
|
||||
|
||||
{:error, %Ecto.Changeset{} = changeset} ->
|
||||
{:noreply,
|
||||
socket
|
||||
|> put_flash(
|
||||
|> put_toast(
|
||||
:error,
|
||||
gettext("Error wishlisting record") <> "," <> inspect(changeset.errors)
|
||||
)}
|
||||
@@ -67,7 +67,7 @@ defmodule MusicLibraryWeb.StatsLive.Index do
|
||||
{:error, reason} ->
|
||||
{:noreply,
|
||||
socket
|
||||
|> put_flash(:error, gettext("Error wishlisting record") <> "," <> inspect(reason))}
|
||||
|> put_toast(:error, gettext("Error wishlisting record") <> "," <> inspect(reason))}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -100,13 +100,13 @@ defmodule MusicLibraryWeb.WishlistLive.Index do
|
||||
{:ok, record} ->
|
||||
{:noreply,
|
||||
socket
|
||||
|> put_flash(:info, gettext("Record wishlisted successfully"))
|
||||
|> put_toast(:info, gettext("Record wishlisted successfully"))
|
||||
|> push_navigate(to: ~p"/wishlist/#{record.id}")}
|
||||
|
||||
{:error, %Ecto.Changeset{} = changeset} ->
|
||||
{:noreply,
|
||||
socket
|
||||
|> put_flash(
|
||||
|> put_toast(
|
||||
:error,
|
||||
gettext("Error wishlisting record") <> "," <> inspect(changeset.errors)
|
||||
)
|
||||
@@ -115,7 +115,7 @@ defmodule MusicLibraryWeb.WishlistLive.Index do
|
||||
{:error, reason} ->
|
||||
{:noreply,
|
||||
socket
|
||||
|> put_flash(:error, gettext("Error wishlisting record") <> "," <> inspect(reason))
|
||||
|> put_toast(:error, gettext("Error wishlisting record") <> "," <> inspect(reason))
|
||||
|> push_patch(to: ~p"/wishlist")}
|
||||
end
|
||||
end
|
||||
@@ -128,7 +128,7 @@ defmodule MusicLibraryWeb.WishlistLive.Index do
|
||||
{:ok, _} ->
|
||||
{:noreply,
|
||||
socket
|
||||
|> put_flash(:info, gettext("Record added to the collection"))
|
||||
|> put_toast(:info, gettext("Record added to the collection"))
|
||||
|> push_patch(to: ~p"/wishlist")}
|
||||
|
||||
{:error, %Ecto.Changeset{} = changeset} ->
|
||||
|
||||
@@ -54,13 +54,13 @@ defmodule MusicLibraryWeb.WishlistLive.Show do
|
||||
{:ok, updated_record} ->
|
||||
{:noreply,
|
||||
socket
|
||||
|> put_flash(:info, gettext("MusicBrainz data refreshed successfully"))
|
||||
|> put_toast(:info, gettext("MusicBrainz data refreshed successfully"))
|
||||
|> assign(:record, updated_record)}
|
||||
|
||||
{:error, reason} ->
|
||||
{:noreply,
|
||||
socket
|
||||
|> put_flash(
|
||||
|> put_toast(
|
||||
:error,
|
||||
gettext("Error refreshing MusicBrainz data") <> "," <> inspect(reason)
|
||||
)}
|
||||
@@ -74,13 +74,13 @@ defmodule MusicLibraryWeb.WishlistLive.Show do
|
||||
{:ok, updated_record} ->
|
||||
{:noreply,
|
||||
socket
|
||||
|> put_flash(:info, gettext("Cover refreshed successfully"))
|
||||
|> put_toast(:info, gettext("Cover refreshed successfully"))
|
||||
|> assign(:record, updated_record)}
|
||||
|
||||
{:error, reason} ->
|
||||
{:noreply,
|
||||
socket
|
||||
|> put_flash(
|
||||
|> put_toast(
|
||||
:error,
|
||||
gettext("Error refreshing Cover") <> "," <> inspect(reason)
|
||||
)}
|
||||
@@ -94,13 +94,13 @@ defmodule MusicLibraryWeb.WishlistLive.Show do
|
||||
{:ok, updated_record} ->
|
||||
{:noreply,
|
||||
socket
|
||||
|> put_flash(:info, gettext("Genres populated successfully"))
|
||||
|> put_toast(:info, gettext("Genres populated successfully"))
|
||||
|> assign(:record, updated_record)}
|
||||
|
||||
{:error, reason} ->
|
||||
{:noreply,
|
||||
socket
|
||||
|> put_flash(
|
||||
|> put_toast(
|
||||
:error,
|
||||
gettext("Error populating genres") <> "," <> inspect(reason)
|
||||
)}
|
||||
@@ -115,7 +115,7 @@ defmodule MusicLibraryWeb.WishlistLive.Show do
|
||||
{:ok, _} ->
|
||||
{:noreply,
|
||||
socket
|
||||
|> put_flash(:info, gettext("Record added to the collection"))
|
||||
|> put_toast(:info, gettext("Record added to the collection"))
|
||||
|> push_navigate(to: ~p"/wishlist")}
|
||||
|
||||
{:error, %Ecto.Changeset{} = changeset} ->
|
||||
@@ -131,12 +131,12 @@ defmodule MusicLibraryWeb.WishlistLive.Show do
|
||||
{:ok, _worker} ->
|
||||
{:noreply,
|
||||
socket
|
||||
|> put_flash(:info, gettext("In progress - record will update automatically"))}
|
||||
|> put_toast(:info, gettext("In progress - record will update automatically"))}
|
||||
|
||||
{:error, reason} ->
|
||||
{:noreply,
|
||||
socket
|
||||
|> put_flash(
|
||||
|> put_toast(
|
||||
:error,
|
||||
gettext("Error") <> "," <> inspect(reason)
|
||||
)}
|
||||
@@ -152,7 +152,7 @@ defmodule MusicLibraryWeb.WishlistLive.Show do
|
||||
def handle_info({:update, record}, socket) do
|
||||
{:noreply,
|
||||
socket
|
||||
|> put_flash(:info, gettext("Record updated in the background"))
|
||||
|> put_toast(:info, gettext("Record updated in the background"))
|
||||
|> assign(:record, record)}
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user