@@ -25,7 +25,7 @@ import {
2525 getPullRequestReviews ,
2626 getRelease ,
2727} from './api/client' ;
28- import { isNotificationStateVisible } from './notifications/filters/filter' ;
28+ import { wouldStateBeHiddenByFilters } from './notifications/filters/filter' ;
2929
3030export async function getGitifySubjectDetails (
3131 notification : Notification ,
@@ -165,22 +165,15 @@ async function getGitifySubjectForDiscussion(
165165 }
166166 }
167167
168- let latestDiscussionComment : DiscussionComment ;
169- if (
170- isNotificationStateVisible (
171- {
172- subject : {
173- state : discussionState ,
174- } ,
175- } as Notification ,
176- settings ,
177- )
178- ) {
179- latestDiscussionComment = getLatestDiscussionComment (
180- discussion . comments . nodes ,
181- ) ;
168+ // Return early if this notification would be hidden by filters
169+ if ( wouldStateBeHiddenByFilters ( discussionState , settings ) ) {
170+ return null ;
182171 }
183172
173+ const latestDiscussionComment = getLatestDiscussionComment (
174+ discussion . comments . nodes ,
175+ ) ;
176+
184177 let discussionUser : SubjectUser = {
185178 login : discussion . author . login ,
186179 html_url : discussion . author . url ,
@@ -231,27 +224,21 @@ async function getGitifySubjectForIssue(
231224
232225 const issueState = issue . state_reason ?? issue . state ;
233226
227+ // Return early if this notification would be hidden by filters
228+ if ( wouldStateBeHiddenByFilters ( issueState , settings ) ) {
229+ return null ;
230+ }
231+
234232 let issueCommentUser : User ;
235233
236- if (
237- isNotificationStateVisible (
238- {
239- subject : {
240- state : issueState ,
241- } ,
242- } as Notification ,
243- settings ,
244- )
245- ) {
246- if ( notification . subject . latest_comment_url ) {
247- const issueComment = (
248- await getIssueOrPullRequestComment (
249- notification . subject . latest_comment_url ,
250- notification . account . token ,
251- )
252- ) . data ;
253- issueCommentUser = issueComment . user ;
254- }
234+ if ( notification . subject . latest_comment_url ) {
235+ const issueComment = (
236+ await getIssueOrPullRequestComment (
237+ notification . subject . latest_comment_url ,
238+ notification . account . token ,
239+ )
240+ ) . data ;
241+ issueCommentUser = issueComment . user ;
255242 }
256243
257244 return {
@@ -280,36 +267,27 @@ async function getGitifySubjectForPullRequest(
280267 }
281268
282269 let prCommentUser : User ;
283- let reviews : GitifyPullRequestReview [ ] ;
284- let linkedIssues : string [ ] ;
285270
271+ // Return early if this notification would be hidden by filters
272+ if ( wouldStateBeHiddenByFilters ( prState , settings ) ) {
273+ return null ;
274+ }
286275 if (
287- isNotificationStateVisible (
288- {
289- subject : {
290- state : prState ,
291- } ,
292- } as Notification ,
293- settings ,
294- )
276+ notification . subject . latest_comment_url &&
277+ notification . subject . latest_comment_url !== notification . subject . url
295278 ) {
296- if (
297- notification . subject . latest_comment_url &&
298- notification . subject . latest_comment_url !== notification . subject . url
299- ) {
300- const prComment = (
301- await getIssueOrPullRequestComment (
302- notification . subject . latest_comment_url ,
303- notification . account . token ,
304- )
305- ) . data ;
306- prCommentUser = prComment . user ;
307- }
308-
309- reviews = await getLatestReviewForReviewers ( notification ) ;
310- linkedIssues = parseLinkedIssuesFromPr ( pr ) ;
279+ const prComment = (
280+ await getIssueOrPullRequestComment (
281+ notification . subject . latest_comment_url ,
282+ notification . account . token ,
283+ )
284+ ) . data ;
285+ prCommentUser = prComment . user ;
311286 }
312287
288+ const reviews = await getLatestReviewForReviewers ( notification ) ;
289+ const linkedIssues = parseLinkedIssuesFromPr ( pr ) ;
290+
313291 return {
314292 number : pr . number ,
315293 state : prState ,
0 commit comments