Skip to content

Commit

Permalink
chore: changed node fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
gentlementlegen committed Sep 15, 2024
1 parent 131a0d8 commit fccde9f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
17 changes: 10 additions & 7 deletions src/helpers/get-comment-details.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
}
4 changes: 2 additions & 2 deletions src/types/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fccde9f

Please sign in to comment.