This commit is contained in:
@@ -134,8 +134,6 @@ defmodule ElixirAiWeb.AiProvidersLive do
|
||||
)
|
||||
|> assign(error: nil)}
|
||||
|
||||
{:error, :already_exists} ->
|
||||
{:noreply, assign(socket, error: "A provider with that name already exists")}
|
||||
|
||||
_ ->
|
||||
{:noreply, assign(socket, error: "Failed to create provider")}
|
||||
|
||||
@@ -7,24 +7,13 @@ defmodule ElixirAiWeb.HomeLive do
|
||||
def mount(_params, _session, socket) do
|
||||
if connected?(socket) do
|
||||
Phoenix.PubSub.subscribe(ElixirAi.PubSub, "ai_providers")
|
||||
send(self(), :load_data)
|
||||
end
|
||||
|
||||
conversations = ConversationManager.list_conversations()
|
||||
|
||||
Logger.debug(
|
||||
"Conversations: #{inspect(conversations, limit: :infinity, printable_limit: :infinity)}"
|
||||
)
|
||||
|
||||
ai_providers = AiProvider.all()
|
||||
|
||||
Logger.debug(
|
||||
"AI Providers: #{inspect(ai_providers, limit: :infinity, printable_limit: :infinity)}"
|
||||
)
|
||||
|
||||
{:ok,
|
||||
socket
|
||||
|> assign(conversations: conversations)
|
||||
|> assign(ai_providers: ai_providers)
|
||||
|> assign(conversations: [])
|
||||
|> assign(ai_providers: [])
|
||||
|> assign(new_name: "")
|
||||
|> assign(error: nil)}
|
||||
end
|
||||
@@ -109,6 +98,25 @@ defmodule ElixirAiWeb.HomeLive do
|
||||
end
|
||||
end
|
||||
|
||||
def handle_info(:load_data, socket) do
|
||||
conversations = ConversationManager.list_conversations()
|
||||
|
||||
Logger.debug(
|
||||
"Conversations: #{inspect(conversations, limit: :infinity, printable_limit: :infinity)}"
|
||||
)
|
||||
|
||||
ai_providers = AiProvider.all()
|
||||
|
||||
Logger.debug(
|
||||
"AI Providers: #{inspect(ai_providers, limit: :infinity, printable_limit: :infinity)}"
|
||||
)
|
||||
|
||||
{:noreply,
|
||||
socket
|
||||
|> assign(conversations: conversations)
|
||||
|> assign(ai_providers: ai_providers)}
|
||||
end
|
||||
|
||||
def handle_info({:provider_added, _attrs}, socket) do
|
||||
{:noreply, assign(socket, ai_providers: AiProvider.all())}
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user