From c2a2fb63b0ffffabba615c01071a186b9d538f94 Mon Sep 17 00:00:00 2001 From: Thorsten Claus Date: Tue, 30 Aug 2022 21:35:13 +0200 Subject: [PATCH] In API dont fetch liked from all comments --- app/presenters/comment_presenter.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/presenters/comment_presenter.rb b/app/presenters/comment_presenter.rb index c02c1a6a2..ae118a9d4 100644 --- a/app/presenters/comment_presenter.rb +++ b/app/presenters/comment_presenter.rb @@ -21,7 +21,14 @@ class CommentPresenter < BasePresenter created_at: created_at, mentioned_people: build_mentioned_people_json, reported: current_user.present? && reports.exists?(user: current_user), - interactions: build_interactions_json + interactions: build_interaction_state + } + end + + def build_interaction_state + { + liked: current_user.present? && likes.where(author: current_user.person).exists?, + likes_count: likes_count } end