From 6dce8ec82ec99117dbe934b716cd3320e67406e7 Mon Sep 17 00:00:00 2001 From: Claudio Ortolina Date: Sat, 21 Mar 2026 21:37:19 +0000 Subject: [PATCH] Load history for chats if there's any --- lib/music_library_web/components/chat.ex | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/music_library_web/components/chat.ex b/lib/music_library_web/components/chat.ex index 544d6df9..9a1bccf4 100644 --- a/lib/music_library_web/components/chat.ex +++ b/lib/music_library_web/components/chat.ex @@ -58,7 +58,20 @@ defmodule MusicLibraryWeb.Components.Chat do socket = 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 socket end