Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/renderer/utils/api/graphql/common.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@ fragment AuthorFields on Actor {
avatar_url: avatarUrl
type: __typename
}

fragment MilestoneFields on Milestone {
state
title
}
18 changes: 11 additions & 7 deletions src/renderer/utils/api/graphql/discussion.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,7 @@ query FetchDiscussionByNumber(
comments(last: $lastComments) {
totalCount
nodes {
...CommentFields
replies(last: $lastReplies) {
totalCount
nodes {
...CommentFields
}
}
...DiscussionCommentFields
}
}
labels(first: $firstLabels) {
Expand All @@ -47,3 +41,13 @@ fragment CommentFields on DiscussionComment {
}
url
}

fragment DiscussionCommentFields on DiscussionComment {
...CommentFields
replies(last: $lastReplies) {
totalCount
nodes {
...CommentFields
}
}
}
24 changes: 12 additions & 12 deletions src/renderer/utils/api/graphql/generated/gql.ts

Large diffs are not rendered by default.

94 changes: 77 additions & 17 deletions src/renderer/utils/api/graphql/generated/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35912,6 +35912,8 @@ export type AuthorFieldsFragment =
| AuthorFields_User_Fragment
;

export type MilestoneFieldsFragment = { __typename?: 'Milestone', state: MilestoneState, title: string };

export type FetchDiscussionByNumberQueryVariables = Exact<{
owner: Scalars['String']['input'];
name: Scalars['String']['input'];
Expand Down Expand Up @@ -35951,6 +35953,20 @@ export type CommentFieldsFragment = { __typename?: 'DiscussionComment', database
| { __typename?: 'User', login: string, html_url: any, avatar_url: any, type: 'User' }
| null };

export type DiscussionCommentFieldsFragment = { __typename?: 'DiscussionComment', databaseId?: number | null, createdAt: any, url: any, replies: { __typename?: 'DiscussionCommentConnection', totalCount: number, nodes?: Array<{ __typename?: 'DiscussionComment', databaseId?: number | null, createdAt: any, url: any, author?:
| { __typename?: 'Bot', login: string, html_url: any, avatar_url: any, type: 'Bot' }
| { __typename?: 'EnterpriseUserAccount', login: string, html_url: any, avatar_url: any, type: 'EnterpriseUserAccount' }
| { __typename?: 'Mannequin', login: string, html_url: any, avatar_url: any, type: 'Mannequin' }
| { __typename?: 'Organization', login: string, html_url: any, avatar_url: any, type: 'Organization' }
| { __typename?: 'User', login: string, html_url: any, avatar_url: any, type: 'User' }
| null } | null> | null }, author?:
| { __typename?: 'Bot', login: string, html_url: any, avatar_url: any, type: 'Bot' }
| { __typename?: 'EnterpriseUserAccount', login: string, html_url: any, avatar_url: any, type: 'EnterpriseUserAccount' }
| { __typename?: 'Mannequin', login: string, html_url: any, avatar_url: any, type: 'Mannequin' }
| { __typename?: 'Organization', login: string, html_url: any, avatar_url: any, type: 'Organization' }
| { __typename?: 'User', login: string, html_url: any, avatar_url: any, type: 'User' }
| null };

export type FetchIssueByNumberQueryVariables = Exact<{
owner: Scalars['String']['input'];
name: Scalars['String']['input'];
Expand All @@ -35974,8 +35990,6 @@ export type FetchIssueByNumberQuery = { __typename?: 'Query', repository?: { __t
| { __typename?: 'User', login: string, html_url: any, avatar_url: any, type: 'User' }
| null } | null> | null }, labels?: { __typename?: 'LabelConnection', nodes?: Array<{ __typename?: 'Label', name: string } | null> | null } | null } | null } | null };

export type MilestoneFieldsFragment = { __typename?: 'Milestone', state: MilestoneState, title: string };

export type FetchPullRequestByNumberQueryVariables = Exact<{
owner: Scalars['String']['input'];
name: Scalars['String']['input'];
Expand Down Expand Up @@ -36007,6 +36021,14 @@ export type FetchPullRequestByNumberQuery = { __typename?: 'Query', repository?:
| { __typename?: 'User', login: string }
| null } | null> | null } | null, labels?: { __typename?: 'LabelConnection', nodes?: Array<{ __typename?: 'Label', name: string } | null> | null } | null, closingIssuesReferences?: { __typename?: 'IssueConnection', nodes?: Array<{ __typename?: 'Issue', number: number } | null> | null } | null } | null } | null };

export type PullRequestReviewFieldsFragment = { __typename?: 'PullRequestReview', state: PullRequestReviewState, author?:
| { __typename?: 'Bot', login: string }
| { __typename?: 'EnterpriseUserAccount', login: string }
| { __typename?: 'Mannequin', login: string }
| { __typename?: 'Organization', login: string }
| { __typename?: 'User', login: string }
| null };

export class TypedDocumentString<TResult, TVariables>
extends String
implements DocumentTypeDecoration<TResult, TVariables>
Expand All @@ -36025,6 +36047,12 @@ export class TypedDocumentString<TResult, TVariables>
return this.value;
}
}
export const MilestoneFieldsFragmentDoc = new TypedDocumentString(`
fragment MilestoneFields on Milestone {
state
title
}
`, {"fragmentName":"MilestoneFields"}) as unknown as TypedDocumentString<MilestoneFieldsFragment, unknown>;
export const AuthorFieldsFragmentDoc = new TypedDocumentString(`
fragment AuthorFields on Actor {
login
Expand All @@ -36048,12 +36076,38 @@ export const CommentFieldsFragmentDoc = new TypedDocumentString(`
avatar_url: avatarUrl
type: __typename
}`, {"fragmentName":"CommentFields"}) as unknown as TypedDocumentString<CommentFieldsFragment, unknown>;
export const MilestoneFieldsFragmentDoc = new TypedDocumentString(`
fragment MilestoneFields on Milestone {
export const DiscussionCommentFieldsFragmentDoc = new TypedDocumentString(`
fragment DiscussionCommentFields on DiscussionComment {
...CommentFields
replies(last: $lastReplies) {
totalCount
nodes {
...CommentFields
}
}
}
fragment AuthorFields on Actor {
login
html_url: url
avatar_url: avatarUrl
type: __typename
}
fragment CommentFields on DiscussionComment {
databaseId
createdAt
author {
...AuthorFields
}
url
}`, {"fragmentName":"DiscussionCommentFields"}) as unknown as TypedDocumentString<DiscussionCommentFieldsFragment, unknown>;
export const PullRequestReviewFieldsFragmentDoc = new TypedDocumentString(`
fragment PullRequestReviewFields on PullRequestReview {
state
title
author {
login
}
}
`, {"fragmentName":"MilestoneFields"}) as unknown as TypedDocumentString<MilestoneFieldsFragment, unknown>;
`, {"fragmentName":"PullRequestReviewFields"}) as unknown as TypedDocumentString<PullRequestReviewFieldsFragment, unknown>;
export const FetchDiscussionByNumberDocument = new TypedDocumentString(`
query FetchDiscussionByNumber($owner: String!, $name: String!, $number: Int!, $lastComments: Int, $lastReplies: Int, $firstLabels: Int, $includeIsAnswered: Boolean!) {
repository(owner: $owner, name: $name) {
Expand All @@ -36070,13 +36124,7 @@ export const FetchDiscussionByNumberDocument = new TypedDocumentString(`
comments(last: $lastComments) {
totalCount
nodes {
...CommentFields
replies(last: $lastReplies) {
totalCount
nodes {
...CommentFields
}
}
...DiscussionCommentFields
}
}
labels(first: $firstLabels) {
Expand All @@ -36100,6 +36148,15 @@ fragment CommentFields on DiscussionComment {
...AuthorFields
}
url
}
fragment DiscussionCommentFields on DiscussionComment {
...CommentFields
replies(last: $lastReplies) {
totalCount
nodes {
...CommentFields
}
}
}`) as unknown as TypedDocumentString<FetchDiscussionByNumberQuery, FetchDiscussionByNumberQueryVariables>;
export const FetchIssueByNumberDocument = new TypedDocumentString(`
query FetchIssueByNumber($owner: String!, $name: String!, $number: Int!, $lastComments: Int, $firstLabels: Int) {
Expand Down Expand Up @@ -36174,10 +36231,7 @@ export const FetchPullRequestByNumberDocument = new TypedDocumentString(`
reviews(last: $lastReviews) {
totalCount
nodes {
state
author {
login
}
...PullRequestReviewFields
}
}
labels(first: $firstLabels) {
Expand All @@ -36202,4 +36256,10 @@ export const FetchPullRequestByNumberDocument = new TypedDocumentString(`
fragment MilestoneFields on Milestone {
state
title
}
fragment PullRequestReviewFields on PullRequestReview {
state
author {
login
}
}`) as unknown as TypedDocumentString<FetchPullRequestByNumberQuery, FetchPullRequestByNumberQueryVariables>;
5 changes: 0 additions & 5 deletions src/renderer/utils/api/graphql/issue.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,3 @@ query FetchIssueByNumber(
}
}
}

fragment MilestoneFields on Milestone {
state
title
}
11 changes: 5 additions & 6 deletions src/renderer/utils/api/graphql/pull.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ query FetchPullRequestByNumber(
reviews(last: $lastReviews) {
totalCount
nodes {
state
author {
login
}
...PullRequestReviewFields
}
}
labels(first: $firstLabels) {
Expand All @@ -55,7 +52,9 @@ query FetchPullRequestByNumber(
}
}

fragment MilestoneFields on Milestone {
fragment PullRequestReviewFields on PullRequestReview {
state
title
author {
login
}
}
17 changes: 2 additions & 15 deletions src/renderer/utils/notifications/handlers/discussion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,11 @@ import type { Notification, Subject } from '../../../typesGitHub';
import { fetchDiscussionByNumber } from '../../api/client';
import type {
CommentFieldsFragment,
FetchDiscussionByNumberQuery,
DiscussionCommentFieldsFragment,
} from '../../api/graphql/generated/graphql';
import { DefaultHandler, defaultHandler } from './default';
import { getNotificationAuthor } from './utils';

type DiscussionComment = NonNullable<
NonNullable<
NonNullable<
NonNullable<
Extract<
NonNullable<FetchDiscussionByNumberQuery['repository']>,
{ __typename?: 'Repository' }
>['discussion']
>
>['comments']['nodes']
>[number]
>;

class DiscussionHandler extends DefaultHandler {
readonly type = 'Discussion';

Expand Down Expand Up @@ -112,7 +99,7 @@ export const discussionHandler = new DiscussionHandler();

export function getClosestDiscussionCommentOrReply(
notification: Notification,
comments: DiscussionComment[],
comments: DiscussionCommentFieldsFragment[],
): CommentFieldsFragment | null {
if (!comments || comments.length === 0) {
return null;
Expand Down
7 changes: 2 additions & 5 deletions src/renderer/utils/notifications/handlers/pullRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,10 @@ import {
} from '../../../types';
import type { Notification, Subject } from '../../../typesGitHub';
import { fetchPullByNumber } from '../../api/client';
import type { FetchPullRequestByNumberQuery } from '../../api/graphql/generated/graphql';
import type { PullRequestReviewFieldsFragment } from '../../api/graphql/generated/graphql';
import { DefaultHandler, defaultHandler } from './default';
import { getNotificationAuthor } from './utils';

type PullRequestReviews =
FetchPullRequestByNumberQuery['repository']['pullRequest']['reviews']['nodes'];

class PullRequestHandler extends DefaultHandler {
readonly type = 'PullRequest' as const;

Expand Down Expand Up @@ -104,7 +101,7 @@ class PullRequestHandler extends DefaultHandler {
export const pullRequestHandler = new PullRequestHandler();

export function getLatestReviewForReviewers(
reviews: PullRequestReviews,
reviews: PullRequestReviewFieldsFragment[],
): GitifyPullRequestReview[] {
if (!reviews.length) {
return null;
Expand Down