summaryrefslogtreecommitdiff
path: root/lib/web/live
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lib/web/live/chat_live.ex7
-rw-r--r--lib/web/live/chat_live.html.heex4
2 files changed, 6 insertions, 5 deletions
diff --git a/lib/web/live/chat_live.ex b/lib/web/live/chat_live.ex
index 8a9f6f2..6902250 100644
--- a/lib/web/live/chat_live.ex
+++ b/lib/web/live/chat_live.ex
@@ -7,7 +7,7 @@ defmodule NolaWeb.ChatLive do
chan = NolaWeb.reformat_chan(chan)
connection = Nola.Irc.Connection.get_network(network, chan)
account = Nola.Account.get(account_id)
- membership = Nola.Membership.of_account(Nola.Account.get("DRgpD4fLf8PDJMLp8Dtb"))
+ membership = Nola.Membership.of_account(Nola.Account.get(account.id))
if account && connection && Enum.member?(membership, {connection.network, chan}) do
{:ok, _} = Registry.register(Nola.PubSub, "#{connection.network}:events", plugin: __MODULE__)
for t <- ["messages", "triggers", "outputs", "events"] do
@@ -88,8 +88,9 @@ defmodule NolaWeb.ChatLive do
handle_info({:irc, nil, message}, socket)
end
- def handle_info({:irc, :text, message}, socket) do
- IO.inspect({:live_message, message})
+ # type is text, out, or nil if it's self?
+ def handle_info({:irc, type, message = %Nola.Message{}}, socket) do
+ IO.inspect({:live_message, type, message})
socket = socket
|> append_to_backlog(message)
{:noreply, socket}
diff --git a/lib/web/live/chat_live.html.heex b/lib/web/live/chat_live.html.heex
index 470604f..c3bb030 100644
--- a/lib/web/live/chat_live.html.heex
+++ b/lib/web/live/chat_live.html.heex
@@ -26,10 +26,10 @@
<%= for message <- @backlog do %>
<%= if is_map(message) && Map.get(message, :__struct__) == Nola.Message do %>
<li class="flex gap-2 place-items-center message"
- data-account-id={message.account.id}>
+ data-account-id={if(message.account, do: message.account.id, else: "bot")}>
<NolaWeb.MessageComponent.content
message={message}
- self={message.account.id == @account_id}
+ self={message.account && message.account.id == @account_id}
text={message.text}
/>
</li>