mirror of
https://github.com/algora-io/tv.git
synced 2025-03-03 14:32:09 +02:00
add dom ids for new chat messages
This commit is contained in:
parent
2600412889
commit
26d5a4b185
@ -42,6 +42,7 @@ const init = () => {
|
||||
|
||||
channel.on("new_msg", (payload) => {
|
||||
const messageItem = document.createElement("div");
|
||||
messageItem.id = `message-${payload.id}`;
|
||||
messageItem.className = "group hover:bg-white/5 relative px-4";
|
||||
|
||||
const senderItem = document.createElement("span");
|
||||
|
@ -13,12 +13,17 @@ defmodule AlgoraWeb.RoomChannel do
|
||||
"room:" <> video_id = socket.topic
|
||||
|
||||
if user do
|
||||
broadcast!(socket, "new_msg", %{user: %{id: user.id, handle: user.handle}, body: body})
|
||||
message =
|
||||
Repo.insert!(%Message{
|
||||
body: body,
|
||||
user_id: user.id,
|
||||
video_id: String.to_integer(video_id)
|
||||
})
|
||||
|
||||
Repo.insert!(%Message{
|
||||
body: body,
|
||||
user_id: user.id,
|
||||
video_id: String.to_integer(video_id)
|
||||
broadcast!(socket, "new_msg", %{
|
||||
user: %{id: user.id, handle: user.handle},
|
||||
id: message.id,
|
||||
body: body
|
||||
})
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user