@@ -32,32 +32,53 @@ async function fetchIssues(owner: string, repo: string) {
3232 headers [' Authorization' ] = ` Bearer ${githubToken } ` ;
3333 }
3434
35- // Try a single request with both labels first
36- const labels = ' good first issue,help wanted' ;
37- const encodedLabels = encodeURIComponent (labels );
38- const url = ` https://api.github.com/repos/${owner }/${repo }/issues?labels=${encodedLabels }&state=open&per_page=10&sort=updated ` ;
35+ // Try multiple requests for different label combinations
36+ const labelCombinations = [
37+ ' good first issue,help wanted' , // Both labels
38+ ' good first issue' , // Just good first issue
39+ ' help wanted' // Just help wanted
40+ ];
3941
40- const response = await fetch ( url , { headers }) ;
42+ let allIssues : any [] = [] ;
4143
42- if (response .status === 403 ) {
43- return [];
44- }
45-
46- if (! response .ok ) {
47- if (response .status === 404 ) {
44+ for (const labels of labelCombinations ) {
45+ const encodedLabels = encodeURIComponent (labels );
46+ const url = ` https://api.github.com/repos/${owner }/${repo }/issues?labels=${encodedLabels }&state=open&per_page=10&sort=updated ` ;
47+
48+ const response = await fetch (url , { headers });
49+
50+ if (response .status === 403 ) {
4851 return [];
4952 }
50- throw new Error (` GitHub API responded with status: ${response .status } ` );
53+
54+ if (! response .ok ) {
55+ if (response .status === 404 ) {
56+ continue ; // Try next combination
57+ }
58+ continue ; // Try next combination
59+ }
60+
61+ const issues = await response .json ();
62+
63+ allIssues = [... allIssues , ... issues ];
64+
65+ // If we found issues, break to avoid duplicates
66+ if (issues .length > 0 ) {
67+ break ;
68+ }
5169 }
5270
53- const issues = await response .json ();
71+ // Remove duplicates based on issue number
72+ const uniqueIssues = allIssues .filter ((issue , index , self ) =>
73+ index === self .findIndex (i => i .number === issue .number )
74+ );
5475
55- if (issues .length === 0 ) {
76+ if (uniqueIssues .length === 0 ) {
5677 return [];
5778 }
5879
5980 // Process and prioritize issues
60- const processedIssues = issues .map ((issue : any ) => {
81+ const processedIssues = uniqueIssues .map ((issue : any ) => {
6182 const hasGoodFirstIssue = issue .labels .some ((label : any ) =>
6283 label .name .toLowerCase ().includes (' good first issue' ) ||
6384 label .name .toLowerCase ().includes (' good-first-issue' )
@@ -94,7 +115,6 @@ if (repoInfo) {
94115<div class =" Card-Issues" >
95116 <div class =" Issues-Header" >
96117 <h4 class =" Issues-Title" >Open Issues</h4 >
97- <span class =" Issues-Count" >{ issues .length } </span >
98118 </div >
99119
100120 { issues .length > 0 ? (
@@ -120,9 +140,9 @@ if (repoInfo) {
120140 </div >
121141 ) : (
122142 <div class = " no-issues" >
123- <div class = " no-issues-icon" >🔍 </div >
124- <div class = " no-issues-text" >No issues found </div >
125- <div class = " no-issues-subtext" >Try checking back later</div >
143+ <div class = " no-issues-icon" >🎉 </div >
144+ <div class = " no-issues-text" >No beginner-friendly issues </div >
145+ <div class = " no-issues-subtext" >All good first issues and help wanted tasks are currently taken! Check back later for new opportunities. </div >
126146 </div >
127147 )}
128148</div >
0 commit comments