From a3be37e86ef743a0ef15f041a94b45d7f344dfec Mon Sep 17 00:00:00 2001 From: Claudio Ortolina Date: Mon, 14 Apr 2025 17:41:11 +0100 Subject: [PATCH] Restore refreshing covers synchronously (better UX) --- lib/music_library_web/live/collection_live/show.ex | 9 ++++++--- priv/gettext/default.pot | 6 +----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/music_library_web/live/collection_live/show.ex b/lib/music_library_web/live/collection_live/show.ex index 12b78fd6..80124444 100644 --- a/lib/music_library_web/live/collection_live/show.ex +++ b/lib/music_library_web/live/collection_live/show.ex @@ -83,11 +83,14 @@ defmodule MusicLibraryWeb.CollectionLive.Show do end def handle_event("refresh_cover", %{"id" => id}, socket) do - case Records.refresh_cover_async(id) do - {:ok, _worker} -> + record = Records.get_record!(id) + + case Records.refresh_cover(record) do + {:ok, record} -> {:noreply, socket - |> put_flash(:info, gettext("Cover scheduled for refresh"))} + |> assign(:record, record) + |> put_flash(:info, gettext("Cover refreshed successfully"))} {:error, reason} -> {:noreply, diff --git a/priv/gettext/default.pot b/priv/gettext/default.pot index cb45c0cf..e37db15a 100644 --- a/priv/gettext/default.pot +++ b/priv/gettext/default.pot @@ -344,6 +344,7 @@ msgstr "" msgid "Refresh LastFm Feed" msgstr "" +#: lib/music_library_web/live/collection_live/show.ex #: lib/music_library_web/live/wishlist_live/show.ex #, elixir-autogen, elixir-format msgid "Cover refreshed successfully" @@ -732,11 +733,6 @@ msgstr "" msgid "Meta" msgstr "" -#: lib/music_library_web/live/collection_live/show.ex -#, elixir-autogen, elixir-format -msgid "Cover scheduled for refresh" -msgstr "" - #: lib/music_library_web/live/collection_live/show.ex #, elixir-autogen, elixir-format msgid "Record updated in the background"