Keep record embedding text in sync with collection page updates
This commit is contained in:
@@ -38,12 +38,6 @@ defmodule MusicLibraryWeb.CollectionLive.Show do
|
|||||||
last_listened_track = Records.get_last_listened_track(record)
|
last_listened_track = Records.get_last_listened_track(record)
|
||||||
play_count = Records.play_count(record) || 0
|
play_count = Records.play_count(record) || 0
|
||||||
|
|
||||||
embedding_text =
|
|
||||||
case Similarity.get_embedding_text(id) do
|
|
||||||
{:ok, text} -> text
|
|
||||||
{:error, _reason} -> gettext("Not available")
|
|
||||||
end
|
|
||||||
|
|
||||||
socket =
|
socket =
|
||||||
if record.selected_release_id do
|
if record.selected_release_id do
|
||||||
socket
|
socket
|
||||||
@@ -55,9 +49,9 @@ defmodule MusicLibraryWeb.CollectionLive.Show do
|
|||||||
socket
|
socket
|
||||||
|> assign(:page_title, page_title(socket.assigns.live_action, record))
|
|> assign(:page_title, page_title(socket.assigns.live_action, record))
|
||||||
|> assign(:record, record)
|
|> assign(:record, record)
|
||||||
|> assign(:embedding_text, embedding_text)
|
|
||||||
|> assign(:last_listened_track, last_listened_track)
|
|> assign(:last_listened_track, last_listened_track)
|
||||||
|> assign(:play_count, play_count)
|
|> assign(:play_count, play_count)
|
||||||
|
|> assign_embedding_text()
|
||||||
|> assign_similar_records()}
|
|> assign_similar_records()}
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -153,7 +147,8 @@ defmodule MusicLibraryWeb.CollectionLive.Show do
|
|||||||
{:noreply,
|
{:noreply,
|
||||||
socket
|
socket
|
||||||
|> assign(:record, record)
|
|> assign(:record, record)
|
||||||
|> assign_similar_records()}
|
|> assign_similar_records()
|
||||||
|
|> assign_embedding_text()}
|
||||||
end
|
end
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
@@ -162,7 +157,8 @@ defmodule MusicLibraryWeb.CollectionLive.Show do
|
|||||||
socket
|
socket
|
||||||
|> put_toast(:info, gettext("Record updated in the background"))
|
|> put_toast(:info, gettext("Record updated in the background"))
|
||||||
|> assign(:record, record)
|
|> assign(:record, record)
|
||||||
|> assign_similar_records()}
|
|> assign_similar_records()
|
||||||
|
|> assign_embedding_text()}
|
||||||
end
|
end
|
||||||
|
|
||||||
def page_title(:show, record) do
|
def page_title(:show, record) do
|
||||||
@@ -204,4 +200,14 @@ defmodule MusicLibraryWeb.CollectionLive.Show do
|
|||||||
|
|
||||||
assign(socket, :similar_records, similar_records)
|
assign(socket, :similar_records, similar_records)
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user