app/cells/decidim/comments/comment_cell.rb in decidim-comments-0.25.2 vs app/cells/decidim/comments/comment_cell.rb in decidim-comments-0.26.0.rc1
- old
+ new
@@ -14,10 +14,11 @@
property :root_commentable
property :created_at
property :deleted_at
property :alignment
property :translated_body
+ property :formatted_body
property :comment_threads
property :accepts_new_comments?
property :edited?
def alignment_badge
@@ -30,17 +31,34 @@
return unless root_commentable.comments_have_votes?
render :votes
end
+ def perform_caching?
+ super && has_replies? == false
+ end
+
private
+ def cache_hash
+ return @hash if defined?(@hash)
+
+ hash = []
+ hash.push(I18n.locale)
+ hash.push(model.must_render_translation?(current_organization) ? 1 : 0)
+ hash.push(model.authored_by?(current_user) ? 1 : 0)
+ hash.push(model.reported_by?(current_user) ? 1 : 0)
+ hash.push(model.cache_key_with_version)
+ hash.push(model.author.cache_key_with_version)
+ @hash = hash.join(Decidim.cache_key_separator)
+ end
+
def decidim_comments
Decidim::Comments::Engine.routes.url_helpers
end
def comment_body
- Decidim::ContentProcessor.render(translated_body)
+ formatted_body
end
def replies
SortedComments.for(model, order_by: order)
end