From 3cf9f4a364ac91cca30799c8379a682139425e71 Mon Sep 17 00:00:00 2001 From: Logan Hunt Date: Fri, 15 Apr 2022 13:00:42 -0600 Subject: Add comments and vote models; pub/sub voting on posts --- lib/aggiedit_web/live/post_live/index.html.heex | 26 ++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'lib/aggiedit_web/live/post_live/index.html.heex') diff --git a/lib/aggiedit_web/live/post_live/index.html.heex b/lib/aggiedit_web/live/post_live/index.html.heex index efb42cb..89767f8 100644 --- a/lib/aggiedit_web/live/post_live/index.html.heex +++ b/lib/aggiedit_web/live/post_live/index.html.heex @@ -18,13 +18,29 @@
<%= for post <- @posts do %>
- <%= if !is_nil(post.upload) do %> - <%= live_redirect to: Routes.post_show_path(@socket, :show, @room, post) do %> -
+
+ <%= + has_vote = Map.has_key?(@votes, post.id) + is_upvote = has_vote && @votes[post.id].is_up + "" + %> +
+ <%= link "", to: "#", phx_click: "upvote", phx_value_id: post.id, class: "bi bi-arrow-up-circle#{if has_vote && is_upvote, do: "-fill", else: ""}" %> +
+
+ <%= post.score %> +
+
+ <%= link "", to: "#", phx_click: "downvote", phx_value_id: post.id, class: "bi bi-arrow-down-circle#{if has_vote && !is_upvote, do: "-fill", else: ""}" %> +
+
+
+ <%= if !is_nil(post.upload) do %> + <%= live_redirect to: Routes.post_show_path(@socket, :show, @room, post) do %> -
+ <% end %> <% end %> - <% end %> +
<%= live_redirect to: Routes.post_show_path(@socket, :show, @room, post) do %>

<%= post.title %>

-- cgit v1.2.3-70-g09d2