Don't use a new request for every comment

This commit is contained in:
Kevin McConnell
2025-01-07 14:14:12 +00:00
parent 21632f30cd
commit 4a4b4113c8
5 changed files with 25 additions and 24 deletions
-1
View File
@@ -15,7 +15,6 @@ class CommentsController < ApplicationController
def update
@comment.update! comment_params
render :show
end
def destroy
+22
View File
@@ -0,0 +1,22 @@
<%= turbo_frame_tag dom_id(comment) do %>
<div class="comment__content flex-inline flex-column full-width border border-radius">
<div class="comment__author flex align-center gap-half">
<strong><%= link_to comment.creator.name, user_path(comment.creator), class: "txt-ink btn btn--plain", data: { turbo_frame: "_top" } %></strong>
<%= link_to bucket_bubble_path(comment.bubble.bucket, comment.bubble, anchor: "comment_#{comment.id}"), class: "txt-undecorated" do %>
<%= tag.time comment.created_at, class: "comment__timestamp" do %>
<%= comment.created_at.strftime("%b %d") %>
<% end %>
<% end %>
<% if comment.creator == Current.user %>
<%= link_to edit_bucket_bubble_comment_path(comment.bubble.bucket, comment.bubble, comment), class: "btn txt-small btn--plain", style: "font-size: 0.4em; opacity: 0.5;" do %>
<%= image_tag "menu-dots-horizontal.svg", class: "icon" %>
<span class="for-screen-reader">Edit</span>
<% end %>
<% end %>
</div>
<div class="comment__body txt-align-start">
<%= sanitize comment.body_html %>
</div>
</div>
<% end %>
+1 -1
View File
@@ -3,5 +3,5 @@
<%= avatar_tag comment.creator, loading: :lazy %>
</figure>
<%= turbo_frame_tag dom_id(comment), src: bucket_bubble_comment_path(comment.bubble.bucket, comment.bubble, comment) %>
<%= render "comments/body", comment: comment %>
<% end %>
+1 -22
View File
@@ -1,22 +1 @@
<%= turbo_frame_tag dom_id(@comment) do %>
<div class="comment__content flex-inline flex-column full-width border border-radius">
<div class="comment__author flex align-center gap-half">
<strong><%= link_to @comment.creator.name, user_path(@comment.creator), class: "txt-ink btn btn--plain", data: { turbo_frame: "_top" } %></strong>
<%= link_to bucket_bubble_path(@comment.bubble.bucket, @comment.bubble, anchor: "comment_#{@comment.id}"), class: "txt-undecorated" do %>
<%= tag.time @comment.created_at, class: "comment__timestamp" do %>
<%= @comment.created_at.strftime("%b %d") %>
<% end %>
<% end %>
<% if @comment.creator == Current.user %>
<%= link_to edit_bucket_bubble_comment_path(@comment.bubble.bucket, @comment.bubble, @comment), class: "btn txt-small btn--plain", style: "font-size: 0.4em; opacity: 0.5;" do %>
<%= image_tag "menu-dots-horizontal.svg", class: "icon" %>
<span class="for-screen-reader">Edit</span>
<% end %>
<% end %>
</div>
<div class="comment__body txt-align-start">
<%= sanitize @comment.body_html %>
</div>
</div>
<% end %>
<%= render "comments/body", comment: @comment %>
+1
View File
@@ -0,0 +1 @@
<%= render "comments/body", comment: @comment %>