Load record embedding for wishlisted records
This commit is contained in:
@@ -14,6 +14,7 @@ defmodule MusicLibraryWeb.WishlistLive.Show do
|
||||
|
||||
alias MusicLibrary.OnlineStoreTemplates
|
||||
alias MusicLibrary.{Records, RecordSets}
|
||||
alias MusicLibrary.Records.Similarity
|
||||
alias MusicLibrary.RecordSets.RecordSet
|
||||
|
||||
@impl true
|
||||
@@ -42,7 +43,8 @@ defmodule MusicLibraryWeb.WishlistLive.Show do
|
||||
|> assign(:page_title, page_title(socket.assigns.live_action, record))
|
||||
|> assign(:record, record)
|
||||
|> assign(:online_store_templates, online_store_templates)
|
||||
|> assign(:record_sets, record_sets)}
|
||||
|> assign(:record_sets, record_sets)
|
||||
|> assign_embedding_text()}
|
||||
end
|
||||
|
||||
@impl true
|
||||
@@ -152,7 +154,8 @@ defmodule MusicLibraryWeb.WishlistLive.Show do
|
||||
def handle_info({MusicLibraryWeb.Components.RecordForm, {:saved, record}}, socket) do
|
||||
{:noreply,
|
||||
socket
|
||||
|> assign(:record, record)}
|
||||
|> assign(:record, record)
|
||||
|> assign_embedding_text()}
|
||||
end
|
||||
|
||||
@impl true
|
||||
@@ -160,7 +163,8 @@ defmodule MusicLibraryWeb.WishlistLive.Show do
|
||||
{:noreply,
|
||||
socket
|
||||
|> put_toast(:info, gettext("Record updated in the background"))
|
||||
|> assign(:record, record)}
|
||||
|> assign(:record, record)
|
||||
|> assign_embedding_text()}
|
||||
end
|
||||
|
||||
def page_title(action, record) do
|
||||
@@ -178,6 +182,13 @@ defmodule MusicLibraryWeb.WishlistLive.Show do
|
||||
)
|
||||
end
|
||||
|
||||
defp assign_embedding_text(socket) do
|
||||
case Similarity.get_embedding_text(socket.assigns.record.id) do
|
||||
{:ok, text} -> assign(socket, :embedding_text, text)
|
||||
{:error, _reason} -> assign(socket, :embedding_text, gettext("Not available"))
|
||||
end
|
||||
end
|
||||
|
||||
defp title_segment(:show), do: gettext("Show")
|
||||
defp title_segment(:edit), do: gettext("Edit")
|
||||
end
|
||||
|
||||
@@ -302,13 +302,14 @@
|
||||
</div>
|
||||
|
||||
<.json_viewer title={gettext("MusicBrainz data")} data={@record.musicbrainz_data} />
|
||||
<.text_viewer title={gettext("Record Embedding")} data={@embedding_text} />
|
||||
|
||||
<.live_component
|
||||
id="record-chat"
|
||||
sheet_id="record-chat-sheet"
|
||||
module={MusicLibraryWeb.Components.RecordChat}
|
||||
record={@record}
|
||||
embedding_text={nil}
|
||||
embedding_text={@embedding_text}
|
||||
/>
|
||||
|
||||
<.structured_modal
|
||||
|
||||
@@ -1666,11 +1666,13 @@ msgid "Running optimize..."
|
||||
msgstr ""
|
||||
|
||||
#: lib/music_library_web/live/collection_live/show.html.heex
|
||||
#: lib/music_library_web/live/wishlist_live/show.html.heex
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Record Embedding"
|
||||
msgstr ""
|
||||
|
||||
#: lib/music_library_web/live/collection_live/show.ex
|
||||
#: lib/music_library_web/live/wishlist_live/show.ex
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Not available"
|
||||
msgstr ""
|
||||
|
||||
@@ -1666,11 +1666,13 @@ msgid "Running optimize..."
|
||||
msgstr ""
|
||||
|
||||
#: lib/music_library_web/live/collection_live/show.html.heex
|
||||
#: lib/music_library_web/live/wishlist_live/show.html.heex
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Record Embedding"
|
||||
msgstr ""
|
||||
|
||||
#: lib/music_library_web/live/collection_live/show.ex
|
||||
#: lib/music_library_web/live/wishlist_live/show.ex
|
||||
#, elixir-autogen, elixir-format, fuzzy
|
||||
msgid "Not available"
|
||||
msgstr ""
|
||||
|
||||
Reference in New Issue
Block a user