@@ -78,14 +78,93 @@ export class FileManager {
7878 }
7979
8080 public filterIssues ( repo : RepositoryTracking , issues : any [ ] ) : any [ ] {
81- return issues ;
81+ let filteredIssues = issues ;
82+
83+ // Apply label filtering
84+ if ( ( repo . enableLabelFilter ?? false ) && ( repo . labelFilters ?. length ?? 0 ) > 0 ) {
85+ filteredIssues = this . applyLabelFilter ( filteredIssues , repo . labelFilterMode ?? "include" , repo . labelFilters ?? [ ] ) ;
86+ }
87+
88+ // Apply assignee filtering
89+ if ( ( repo . enableAssigneeFilter ?? false ) ) {
90+ filteredIssues = this . applyAssigneeFilter ( filteredIssues , repo . assigneeFilterMode ?? "assigned-to-me" , repo . assigneeFilters ?? [ ] ) ;
91+ }
92+
93+ return filteredIssues ;
94+ }
95+
96+ private applyLabelFilter ( items : any [ ] , filterMode : "include" | "exclude" , labelFilters : string [ ] ) : any [ ] {
97+ return items . filter ( ( item ) => {
98+ if ( ! item . labels || ! Array . isArray ( item . labels ) ) {
99+ // If no labels, only include in "exclude" mode (since we're excluding specific labels)
100+ return filterMode === "exclude" ;
101+ }
102+
103+ const itemLabels = item . labels . map ( ( label : any ) =>
104+ typeof label === 'string' ? label : label . name
105+ ) ;
106+
107+ const hasMatchingLabel = labelFilters . some ( filterLabel =>
108+ itemLabels . includes ( filterLabel )
109+ ) ;
110+
111+ // Include mode: only include items that have at least one of the specified labels
112+ // Exclude mode: exclude items that have any of the specified labels
113+ return filterMode === "include" ? hasMatchingLabel : ! hasMatchingLabel ;
114+ } ) ;
115+ }
116+
117+ private applyAssigneeFilter ( items : any [ ] , filterMode : "assigned-to-me" | "assigned-to-specific" | "unassigned" | "any-assigned" , assigneeFilters : string [ ] ) : any [ ] {
118+ return items . filter ( ( item ) => {
119+ const assignees = item . assignees || [ ] ;
120+ const assigneeUsernames = assignees . map ( ( assignee : any ) => assignee . login || assignee ) ;
121+
122+ switch ( filterMode ) {
123+ case "assigned-to-me" :
124+ // Get current user from the item's context or use a stored current user
125+ const currentUser = this . getCurrentUser ( ) ;
126+ return assigneeUsernames . includes ( currentUser ) ;
127+
128+ case "assigned-to-specific" :
129+ // Check if any of the specified assignees are assigned
130+ return assigneeFilters . some ( filterUser => assigneeUsernames . includes ( filterUser ) ) ;
131+
132+ case "unassigned" :
133+ // Only include items with no assignees
134+ return assigneeUsernames . length === 0 ;
135+
136+ case "any-assigned" :
137+ // Only include items that have at least one assignee
138+ return assigneeUsernames . length > 0 ;
139+
140+ default :
141+ return true ;
142+ }
143+ } ) ;
144+ }
145+
146+ private getCurrentUser ( ) : string {
147+ // Access the current user from the GitHubClient through the main plugin
148+ return this . gitHubClient ? this . gitHubClient . getCurrentUser ( ) : "" ;
82149 }
83150
84151 public filterPullRequests (
85152 repo : RepositoryTracking ,
86153 pullRequests : any [ ] ,
87154 ) : any [ ] {
88- return pullRequests ;
155+ let filteredPullRequests = pullRequests ;
156+
157+ // Apply label filtering
158+ if ( ( repo . enablePrLabelFilter ?? false ) && ( repo . prLabelFilters ?. length ?? 0 ) > 0 ) {
159+ filteredPullRequests = this . applyLabelFilter ( filteredPullRequests , repo . prLabelFilterMode ?? "include" , repo . prLabelFilters ?? [ ] ) ;
160+ }
161+
162+ // Apply assignee filtering
163+ if ( ( repo . enablePrAssigneeFilter ?? false ) ) {
164+ filteredPullRequests = this . applyAssigneeFilter ( filteredPullRequests , repo . prAssigneeFilterMode ?? "assigned-to-me" , repo . prAssigneeFilters ?? [ ] ) ;
165+ }
166+
167+ return filteredPullRequests ;
89168 }
90169
91170 public async cleanupEmptyFolders ( ) : Promise < void > {
@@ -274,11 +353,20 @@ export class FileManager {
274353 const file = this . app . vault . getAbstractFileByPath ( `${ issueFolderPath } /${ fileName } ` ) ;
275354
276355 const [ owner , repoName ] = repo . repository . split ( "/" ) ;
277- const comments = await this . gitHubClient . fetchIssueComments (
278- owner ,
279- repoName ,
280- issue . number ,
281- ) ;
356+
357+ // Only fetch comments if they should be included
358+ let comments : any [ ] = [ ] ;
359+ if ( repo . includeIssueComments ) {
360+ comments = await this . gitHubClient . fetchIssueComments (
361+ owner ,
362+ repoName ,
363+ issue . number ,
364+ ) ;
365+ } else {
366+ this . noticeManager . debug (
367+ `Skipping comments for issue ${ issue . number } : repository setting disabled` ,
368+ ) ;
369+ }
282370
283371 let content = this . createIssueContent ( issue , repo , comments ) ;
284372
@@ -366,11 +454,20 @@ export class FileManager {
366454 const file = this . app . vault . getAbstractFileByPath ( `${ pullRequestFolderPath } /${ fileName } ` ) ;
367455
368456 const [ owner , repoName ] = repo . repository . split ( "/" ) ;
369- const comments = await this . gitHubClient . fetchPullRequestComments (
370- owner ,
371- repoName ,
372- pr . number ,
373- ) ;
457+
458+ // Only fetch comments if they should be included
459+ let comments : any [ ] = [ ] ;
460+ if ( repo . includePullRequestComments ) {
461+ comments = await this . gitHubClient . fetchPullRequestComments (
462+ owner ,
463+ repoName ,
464+ pr . number ,
465+ ) ;
466+ } else {
467+ this . noticeManager . debug (
468+ `Skipping comments for PR ${ pr . number } : repository setting disabled` ,
469+ ) ;
470+ }
374471
375472 let content = this . createPullRequestContent ( pr , repo , comments ) ;
376473
0 commit comments