From 2f42bc46d49033a3ae2d65c047bfa2cbdbe4081f Mon Sep 17 00:00:00 2001 From: Mac Siri Date: Thu, 4 Nov 2021 10:38:29 -0400 Subject: [PATCH] Add collection cache in articles/full_comment_area (#15278) * Add collection cache in articles/full_comment_area * Add missing file --- app/views/articles/_comment_tree.html.erb | 2 ++ app/views/articles/_full_comment_area.html.erb | 6 +----- 2 files changed, 3 insertions(+), 5 deletions(-) create mode 100644 app/views/articles/_comment_tree.html.erb diff --git a/app/views/articles/_comment_tree.html.erb b/app/views/articles/_comment_tree.html.erb new file mode 100644 index 000000000..e46f155c7 --- /dev/null +++ b/app/views/articles/_comment_tree.html.erb @@ -0,0 +1,2 @@ +<% comment, sub_comments = comment_node %> +<%= nested_comments(tree: { comment => sub_comments }, commentable: @article, is_view_root: true) %> diff --git a/app/views/articles/_full_comment_area.html.erb b/app/views/articles/_full_comment_area.html.erb index 4c2cb6149..80c38b133 100644 --- a/app/views/articles/_full_comment_area.html.erb +++ b/app/views/articles/_full_comment_area.html.erb @@ -28,11 +28,7 @@
<% if @article.comments_count > 0 %> - <% Comment.tree_for(@article, @comments_to_show_count).each do |comment, sub_comments| %> - <% cache ["comment_root_cached_tree", comment] do %> - <%= tree_for(comment, sub_comments, @article) %> - <% end %> - <% end %> + <%= render partial: "articles/comment_tree", collection: Comment.tree_for(@article, @comments_to_show_count), as: :comment_node, cached: proc { |comment, _sub_comments| comment } %> <% end %>