Pick color extraction strategy from dropdown

This commit is contained in:
Claudio Ortolina
2025-06-08 20:01:49 +01:00
parent 2bbb91769d
commit 2cc1d7ca8f
10 changed files with 185 additions and 23 deletions
@@ -116,6 +116,26 @@ defmodule MusicLibraryWeb.CollectionLive.Show do
end
end
def handle_event("extract_colors", %{"id" => id, "method" => method}, socket) do
record = Records.get_record!(id)
method = String.to_existing_atom(method)
case Records.extract_colors_async(record, method) do
{:ok, _worker} ->
{:noreply,
socket
|> put_flash(:info, gettext("In progress - record will update automatically"))}
{:error, reason} ->
{:noreply,
socket
|> put_flash(
:error,
gettext("Error") <> "," <> inspect(reason)
)}
end
end
@impl true
def handle_info({MusicLibraryWeb.FormComponent, {:saved, record}}, socket) do
{:noreply, assign(socket, :record, record)}