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 +- lib/aggiedit_web/live/post_live/form_component.ex | 4 +- lib/aggiedit_web/live/post_live/show.html.heex | 70 ++++------------------- lib/aggiedit_web/templates/layout/root.html.heex | 1 + 4 files changed, 19 insertions(+), 61 deletions(-) (limited to 'lib') 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 diff --git a/lib/aggiedit_web/live/post_live/form_component.ex b/lib/aggiedit_web/live/post_live/form_component.ex index 8714277..43e6b9b 100644 --- a/lib/aggiedit_web/live/post_live/form_component.ex +++ b/lib/aggiedit_web/live/post_live/form_component.ex @@ -39,7 +39,9 @@ defmodule AggieditWeb.PostLive.FormComponent do filename = "#{upload.uuid}.#{extension}" dest = Path.join("priv/static/uploads", filename) - File.cp!(data.path, dest) + with :ok <- File.mkdir_p(Path.dirname(dest)) do + File.cp!(data.path, dest) + end {:ok, upload} = Uploads.create_upload(%{ file: filename, diff --git a/lib/aggiedit_web/live/post_live/show.html.heex b/lib/aggiedit_web/live/post_live/show.html.heex index b89999b..f0d1f41 100644 --- a/lib/aggiedit_web/live/post_live/show.html.heex +++ b/lib/aggiedit_web/live/post_live/show.html.heex @@ -1,4 +1,3 @@ -
@@ -6,7 +5,7 @@
<%= if Ecto.assoc_loaded?(@post.upload) && !is_nil(@post.upload) do %> - + <% end %>
@@ -16,21 +15,18 @@ <%= live_patch "Edit", to: Routes.post_show_path(@socket, :edit, @room, @post), class: "button" %> | <% end %> <%= live_redirect "Back", to: Routes.post_index_path(@socket, :index, @room) %> -
-
- -
-
-
-
-
Chat
-
-
    -
-
-
-
+
+
+
+
+
+
+ + +
+ +
@@ -47,45 +43,3 @@ /> <% end %> - - diff --git a/lib/aggiedit_web/templates/layout/root.html.heex b/lib/aggiedit_web/templates/layout/root.html.heex index 14c7605..ec7ff0d 100644 --- a/lib/aggiedit_web/templates/layout/root.html.heex +++ b/lib/aggiedit_web/templates/layout/root.html.heex @@ -8,6 +8,7 @@ <%= live_title_tag assigns[:page_title] || "Aggiedit" %> + -- cgit v1.2.3-70-g09d2