summaryrefslogtreecommitdiff
path: root/lib/aggiedit_web/live/post_live/index.html.heex
diff options
context:
space:
mode:
authorLogan Hunt <loganhunt@simponic.xyz>2022-04-14 11:43:34 -0600
committerLogan Hunt <loganhunt@simponic.xyz>2022-04-14 11:43:34 -0600
commitcc58a376a94c28532121fca2e1ab1d0e7de11046 (patch)
treecb31a620c444e18ad8efa535ec946a7bcd792d6f /lib/aggiedit_web/live/post_live/index.html.heex
parentddfab312f73a3f3e15ceb6fec7d350500adb53d6 (diff)
downloadaggiedit-cc58a376a94c28532121fca2e1ab1d0e7de11046.tar.gz
aggiedit-cc58a376a94c28532121fca2e1ab1d0e7de11046.zip
Add pubsub
Diffstat (limited to 'lib/aggiedit_web/live/post_live/index.html.heex')
-rw-r--r--lib/aggiedit_web/live/post_live/index.html.heex55
1 files changed, 22 insertions, 33 deletions
diff --git a/lib/aggiedit_web/live/post_live/index.html.heex b/lib/aggiedit_web/live/post_live/index.html.heex
index 7532685..efb42cb 100644
--- a/lib/aggiedit_web/live/post_live/index.html.heex
+++ b/lib/aggiedit_web/live/post_live/index.html.heex
@@ -15,39 +15,28 @@
<% end %>
<span><%= live_patch "New Post", to: Routes.post_index_path(@socket, :new, @room) %></span>
-<%= for post <- @posts do %>
- <div class="card d-flex flex-row align-items-center p-2 m-2 shadow">
- <%= if !is_nil(post.upload) do %>
- <%= live_redirect to: Routes.post_show_path(@socket, :show, @room, post) do %>
- <div class="card-image d-flex justify-content-center" style="width: 100px">
- <img class="fluid-img thumbnail" src={Routes.static_path(@socket, "/uploads/#{post.upload.file}")} />
- </div>
+<div id="posts" phx-update="prepend">
+ <%= for post <- @posts do %>
+ <div id={"post-#{post.id}"} class="card d-flex flex-row align-items-center p-2 m-2 shadow">
+ <%= if !is_nil(post.upload) do %>
+ <%= live_redirect to: Routes.post_show_path(@socket, :show, @room, post) do %>
+ <div class="card-image d-flex justify-content-center" style="width: 100px">
+ <img class="fluid-img thumbnail" src={Routes.static_path(@socket, "/uploads/#{post.upload.file}")} />
+ </div>
+ <% end %>
<% end %>
- <% end %>
- <div class="card-body">
- <%= live_redirect to: Routes.post_show_path(@socket, :show, @room, post) do %>
- <h4 class="card-title"><%= post.title %></h4>
- <% end %>
- <h6 class="card-subtitle mb-2"><span class="text-muted">aggie/</span><%= post.user.username %></h6>
- <p class="card-text"><%= post.body %></p>
+ <div class="card-body">
+ <%= live_redirect to: Routes.post_show_path(@socket, :show, @room, post) do %>
+ <h4 class="card-title"><%= post.title %></h4>
+ <% end %>
+ <h6 class="card-subtitle mb-2"><span class="text-muted">aggie/</span><%= post.user.username %></h6>
+ <p class="card-text"><%= post.body %></p>
- <%= if Aggiedit.Roles.guard?(@current_user, :edit, post) && Aggiedit.Roles.guard?(@current_user, :edit, post) do %>
- <span><%= live_patch "Edit", to: Routes.post_index_path(@socket, :edit, @room, post) %></span>
- <span><%= link "Delete", to: "#", phx_click: "delete", phx_value_id: post.id %></span>
- <% end %>
+ <%= if Aggiedit.Roles.guard?(@current_user, :edit, post) && Aggiedit.Roles.guard?(@current_user, :edit, post) do %>
+ <span><%= live_patch "Edit", to: Routes.post_index_path(@socket, :edit, @room, post) %></span>
+ <span><%= link "Delete", to: "#", phx_click: "delete", phx_value_id: post.id %></span>
+ <% end %>
+ </div>
</div>
- </div>
-<!--
- <div class=>
- </div>
- <tr id={"post-#{post.id}"}>
- <td><%= post.title %></td>
- <td><%= post.body %></td>
-
- <td>
- <span></span>
- </td>
- </tr>
- -->
-<% end %>
-
+ <% end %>
+</div>