diff --git a/app/javascript/components/CommentUserIcon.jsx b/app/javascript/components/CommentUserIcon.jsx index c90fe6057df..3e9b726cac4 100644 --- a/app/javascript/components/CommentUserIcon.jsx +++ b/app/javascript/components/CommentUserIcon.jsx @@ -1,7 +1,7 @@ import React from 'react' -export default function CommentUserIcon({ comment, report }) { - const roleClass = `is-${report.user.primary_role}` +export default function CommentUserIcon({ comment }) { + const roleClass = `is-${comment.primary_role}` return ( {report.comments.map((comment) => { return ( - + ) })} diff --git a/app/views/api/comments/_user_icons.json.jbuilder b/app/views/api/comments/_user_icons.json.jbuilder index 0c293b3f8eb..5d61fcba7bf 100644 --- a/app/views/api/comments/_user_icons.json.jbuilder +++ b/app/views/api/comments/_user_icons.json.jbuilder @@ -1,12 +1,13 @@ -json.hasAnyComments comments.present? -if comments.present? - json.numberOfComments comments.size - json.lastCommentDatetime comments.last.updated_at.to_datetime - json.lastCommentDate l comments.last.updated_at, format: :date_and_time +json.hasAnyComments report.comments.present? +if report.comments.present? + json.numberOfComments report.comments.size + json.lastCommentDatetime report.comments.last.updated_at.to_datetime + json.lastCommentDate l report.comments.last.updated_at, format: :date_and_time json.comments do - json.array! comments.commented_users do |user| + json.array! report.commented_users.uniq do |user| json.user_icon user.avatar_url json.user_id user.id + json.primary_role user.primary_role end end end diff --git a/app/views/api/reports/index.json.jbuilder b/app/views/api/reports/index.json.jbuilder index ea65cc82726..3f11d1f24c3 100644 --- a/app/views/api/reports/index.json.jbuilder +++ b/app/views/api/reports/index.json.jbuilder @@ -1,7 +1,7 @@ json.reports @reports do |report| json.partial! "api/reports/report", report: report json.partial! "api/reports/checks", checks: report.checks - json.partial! "api/comments/user_icons", comments: report.comments + json.partial! "api/comments/user_icons", report: report json.user do json.partial! "api/users/user", user: report.user end diff --git a/app/views/api/reports/sad_streak/index.json.jbuilder b/app/views/api/reports/sad_streak/index.json.jbuilder index 82a690423a7..2998f10b77e 100644 --- a/app/views/api/reports/sad_streak/index.json.jbuilder +++ b/app/views/api/reports/sad_streak/index.json.jbuilder @@ -1,7 +1,7 @@ json.reports @reports do |report| json.partial! "api/reports/report", report: report json.partial! "api/reports/checks", checks: report.checks - json.partial! "api/comments/user_icons", comments: report.comments + json.partial! "api/comments/user_icons", report: report json.user do json.partial! "api/users/user", user: report.user end diff --git a/app/views/api/reports/unchecked/index.json.jbuilder b/app/views/api/reports/unchecked/index.json.jbuilder index 5a20eb91f46..1e869e8cfb4 100644 --- a/app/views/api/reports/unchecked/index.json.jbuilder +++ b/app/views/api/reports/unchecked/index.json.jbuilder @@ -1,6 +1,6 @@ json.reports @reports do |report| json.partial! "api/reports/report", report: report - json.partial! "api/comments/user_icons", comments: report.comments + json.partial! "api/comments/user_icons", report: report json.user do json.partial! "api/users/user", user: report.user end