Load history for chats if there's any

This commit is contained in:
Claudio Ortolina
2026-03-21 21:37:19 +00:00
parent dbb66c4094
commit 6dce8ec82e
+14 -1
View File
@@ -58,7 +58,20 @@ defmodule MusicLibraryWeb.Components.Chat do
socket = socket =
if changed?(socket, :entity) or changed?(socket, :musicbrainz_id) do if changed?(socket, :entity) or changed?(socket, :musicbrainz_id) do
assign(socket, :has_history, check_chat_history(socket.assigns)) has_history = check_chat_history(socket.assigns)
if has_history do
chats = Chats.list_chats(socket.assigns.entity, socket.assigns.musicbrainz_id)
socket
|> assign(:has_history, true)
|> assign(:chats, chats)
|> assign(:view, :list)
else
socket
|> assign(:has_history, false)
|> assign(:view, :active)
end
else else
socket socket
end end