/comments: add vote buttons beneath thumbnails on /comments page.
Also fix an N+1 queries problem.
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
.posts-container {
|
||||
article.post-preview {
|
||||
.post-score a {
|
||||
@include inactive-link;
|
||||
}
|
||||
|
||||
@@ -84,11 +84,6 @@ class CommentsController < ApplicationController
|
||||
@limit = params.fetch(:limit, 20)
|
||||
@posts = Post.where.not(last_comment_bumped_at: nil).user_tag_match(params[:tags]).reorder("last_comment_bumped_at DESC NULLS LAST").paginate(params[:page], limit: @limit, search_count: params[:search])
|
||||
|
||||
if request.format.html?
|
||||
@posts = @posts.includes(comments: [:creator])
|
||||
@posts = @posts.includes(comments: [:votes]) if CurrentUser.is_member?
|
||||
end
|
||||
|
||||
respond_with(@posts)
|
||||
end
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
<%= render "post_sets/blank" %>
|
||||
<% end %>
|
||||
|
||||
<% @posts.select(&:visible?).each do |post| %>
|
||||
<% @posts.includes(:media_asset, :uploader, :vote_by_current_user, comments: [:creator, :votes]).select(&:visible?).each do |post| %>
|
||||
<%= tag.div id: "post_#{post.id}", **PostPreviewComponent.new(post: post).article_attrs("post space-x-4") do %>
|
||||
<%= post_preview(post, show_deleted: true) %>
|
||||
<%= post_preview(post, show_deleted: true, show_votes: true) %>
|
||||
|
||||
<div class="flex-1">
|
||||
<%= render "comments/partials/index/header", post: post %>
|
||||
|
||||
@@ -12,10 +12,6 @@
|
||||
<strong>Rating</strong>
|
||||
<%= post.pretty_rating %>
|
||||
</span>
|
||||
<span class="info">
|
||||
<strong>Score</strong>
|
||||
<%= render_post_votes post, current_user: CurrentUser.user %>
|
||||
</span>
|
||||
</div>
|
||||
<div class="row list-of-tags">
|
||||
<strong>Tags</strong>
|
||||
|
||||
Reference in New Issue
Block a user