From 0c657edfcc3271d9cc6c5717b1f47a8b4ea34744 Mon Sep 17 00:00:00 2001 From: hirano-vm4 Date: Fri, 29 Mar 2024 22:22:53 +0900 Subject: [PATCH] =?UTF-8?q?/reports=E3=81=A7=E3=83=A6=E3=83=BC=E3=82=B6?= =?UTF-8?q?=E3=83=BC=E3=83=AD=E3=83=BC=E3=83=AB=E6=83=85=E5=A0=B1=E3=81=8C?= =?UTF-8?q?=E5=8F=96=E5=BE=97=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/javascript/components/CommentUserIcon.jsx | 4 ++-- app/javascript/components/ListComment.jsx | 6 +----- app/views/api/comments/_user_icons.json.jbuilder | 13 +++++++------ app/views/api/reports/index.json.jbuilder | 2 +- .../api/reports/sad_streak/index.json.jbuilder | 2 +- app/views/api/reports/unchecked/index.json.jbuilder | 2 +- 6 files changed, 13 insertions(+), 16 deletions(-) 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