From fccde9f0d799e3a084d3321b84f723aae737a7e6 Mon Sep 17 00:00:00 2001 From: Mentlegen <9807008+gentlementlegen@users.noreply.github.com> Date: Sun, 15 Sep 2024 09:16:33 +0900 Subject: [PATCH] chore: changed node fetch --- src/helpers/get-comment-details.ts | 17 ++++++++++------- src/types/requests.ts | 4 ++-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/helpers/get-comment-details.ts b/src/helpers/get-comment-details.ts index e705c226..94bf450f 100644 --- a/src/helpers/get-comment-details.ts +++ b/src/helpers/get-comment-details.ts @@ -5,14 +5,17 @@ import { QUERY_COMMENT_DETAILS } from "../types/requests"; export async function getMinimizedCommentStatus(comments: GitHubIssueComment[]) { const octokit = getOctokitInstance(); + const commentsData = await octokit.graphql<{ nodes?: IssueComment[] }>(QUERY_COMMENT_DETAILS, { + node_ids: comments.map((o) => o.node_id), + }); - for (const comment of comments) { - const commentData = await octokit.graphql<{ node?: IssueComment }>(QUERY_COMMENT_DETAILS, { - node_id: comment.node_id, - }); - // For each comment we add the 'isMinimized' info, which corresponds to a collapsed comment - if (commentData.node) { - comment.isMinimized = commentData.node.isMinimized; + if (commentsData.nodes?.length) { + for (const commentNode of commentsData.nodes) { + const comment = comments.find((o) => o.node_id === commentNode.id); + // For each comment we add the 'isMinimized' info, which corresponds to a collapsed comment + if (comment) { + comment.isMinimized = commentNode.isMinimized; + } } } } diff --git a/src/types/requests.ts b/src/types/requests.ts index b93397b5..3fd25f89 100644 --- a/src/types/requests.ts +++ b/src/types/requests.ts @@ -35,8 +35,8 @@ export const LINKED_PULL_REQUESTS = /* GraphQL */ ` `; export const QUERY_COMMENT_DETAILS = /* GraphQL */ ` - query commentDetails($node_id: ID!) { - node(id: $node_id) { + query commentDetails($node_ids: [ID!]!) { + nodes(ids: $node_ids) { ... on IssueComment { id isMinimized