From f6b262ea668bfaef48be40efb809e791258e2417 Mon Sep 17 00:00:00 2001 From: Logan Hunt Date: Thu, 21 Apr 2022 17:23:17 -0600 Subject: Updates to frontend and fix a bug where first socket assignment failed --- lib/aggiedit_web/channels/post_channel.ex | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/aggiedit_web/channels/post_channel.ex') diff --git a/lib/aggiedit_web/channels/post_channel.ex b/lib/aggiedit_web/channels/post_channel.ex index ea79d76..2b1c9b5 100644 --- a/lib/aggiedit_web/channels/post_channel.ex +++ b/lib/aggiedit_web/channels/post_channel.ex @@ -24,13 +24,14 @@ defmodule AggieditWeb.PostChannel do |> Enum.map(fn c -> Aggiedit.Post.Comment.serialize(c) end) push(socket, "initial-comments", %{:comments => comments}) + broadcast!(socket, "join", %{user: socket.assigns.current_user.username}) {:noreply, socket} end @impl true - def handle_in("send", %{"body" => comment}=body, socket) do + def handle_in("send", %{"body" => comment}, socket) do {:ok, comment} = Rooms.comment_post(socket.assigns.post, socket.assigns.current_user, comment) broadcast!(socket, "shout", Aggiedit.Post.Comment.serialize(comment)) {:reply, :ok, socket} end -end \ No newline at end of file +end -- cgit v1.2.3-70-g09d2