Skip to content

Commit 5a198b7

Browse files
committed
refactor(api): use graphql api for issue and pull request enrichment
Signed-off-by: Adam Setch <[email protected]>
1 parent fc37b54 commit 5a198b7

File tree

2 files changed

+26
-19
lines changed

2 files changed

+26
-19
lines changed

src/renderer/typesGitHub.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@ export type SubjectType =
4646
| 'RepositoryVulnerabilityAlert'
4747
| 'WorkflowRun';
4848

49-
export type IssueStateType = 'closed' | 'open';
50-
51-
export type IssueStateReasonType = 'completed' | 'not_planned' | 'reopened';
52-
5349
export type UserType =
5450
| 'Bot'
5551
| 'EnterpriseUserAccount'
@@ -66,8 +62,6 @@ export type PullRequestStateType = 'closed' | 'draft' | 'merged' | 'open';
6662
export type StateType =
6763
| CheckSuiteStatus
6864
| DiscussionStateType
69-
| IssueStateType
70-
| IssueStateReasonType
7165
| PullRequestStateType
7266
| IssueState
7367
| IssueStateReason
@@ -88,16 +82,6 @@ export type CheckSuiteStatus =
8882
| 'timed_out'
8983
| 'waiting';
9084

91-
export type PullRequestReviewAuthorAssociation =
92-
| 'COLLABORATOR'
93-
| 'CONTRIBUTOR'
94-
| 'FIRST_TIMER'
95-
| 'FIRST_TIME_CONTRIBUTOR'
96-
| 'MANNEQUIN'
97-
| 'MEMBER'
98-
| 'NONE'
99-
| 'OWNER';
100-
10185
// TODO: #828 Add explicit types for GitHub API response vs Gitify Notifications object
10286
export type Notification = GitHubNotification & GitifyNotification;
10387

src/renderer/utils/notifications/filters/state.ts

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ import type {
55
TypeDetails,
66
} from '../../../types';
77
import type { Notification } from '../../../typesGitHub';
8+
import {
9+
DiscussionCloseReason,
10+
DiscussionState,
11+
IssueState,
12+
IssueStateReason,
13+
PullRequestState,
14+
} from '../../api/graphql/generated/graphql';
815
import type { Filter } from './types';
916

1017
const STATE_TYPE_DETAILS: Record<FilterStateType, TypeDetails> = {
@@ -63,9 +70,25 @@ export const stateFilter: Filter<FilterStateType> = {
6370
notification: Notification,
6471
stateType: FilterStateType,
6572
): boolean {
66-
const allOpenStates = ['open', 'reopened'];
67-
const allClosedStates = ['closed', 'completed', 'not_planned'];
68-
const allMergedStates = ['merged'];
73+
const allOpenStates = [
74+
DiscussionState.Open,
75+
IssueState.Open,
76+
IssueStateReason.Reopened,
77+
PullRequestState.Open,
78+
'open',
79+
'reopened',
80+
];
81+
const allClosedStates = [
82+
DiscussionState.Closed,
83+
IssueState.Closed,
84+
IssueStateReason.NotPlanned,
85+
PullRequestState.Closed,
86+
87+
'closed',
88+
'completed',
89+
'not_planned',
90+
];
91+
const allMergedStates = [PullRequestState.Merged, 'merged'];
6992
const allDraftStates = ['draft'];
7093
const allFilterableStates = [
7194
...allOpenStates,

0 commit comments

Comments
 (0)