@@ -203,11 +203,14 @@ export function pageReads(): PageReads {
203203 } ) ) ;
204204 }
205205
206- /** Every open pull request, or only the newest page of GitHub's list when `newest` asks for no more than one page. */
207- async function openPulls ( repo : string , newest : boolean ) {
206+ /** Every open pull request, or only those into `base` when it is set, or only the newest page of GitHub's list when `newest` asks for no more than one page. */
207+ async function openPulls ( repo : string , newest : boolean , base : string | null ) {
208208 const rows : Array < { number : number ; title : string } > = [ ] ;
209+ const query = base === null ? "is:pr is:open" : `is:pr is:open base:"${ base } "` ;
209210 for ( let page = 1 ; ; page ++ ) {
210- const route = ( await json ( `/${ repo } /pulls?q=${ encodeURIComponent ( "is:pr is:open" ) } &page=${ page } ` ) ) . payload . repoPullsDashboardContentRoute ;
211+ const route = ( await json ( `/${ repo } /pulls?q=${ encodeURIComponent ( query ) } &page=${ page } ` ) ) . payload . repoPullsDashboardContentRoute ;
212+ // With nothing open the route leaves out its results and pages.
213+ if ( route . openCount === 0 ) return rows ;
211214 rows . push ( ...( route . results as any [ ] ) . map ( ( row ) => ( { number : row . number , title : row . title , draft : row . displayState === "REPO_PULL_REQUEST_DISPLAY_STATE_DRAFT" , head : { sha : row . headSha } , labels : row . labels } ) ) ) ;
212215 if ( newest || page >= route . totalPages ) return rows ;
213216 }
@@ -254,7 +257,7 @@ export function pageReads(): PageReads {
254257 if ( ( match = COMMITS . exec ( pathname ) ) ) return commits ( match [ 1 ] ! , Number ( match [ 2 ] ) ) ;
255258 if ( ( match = ISSUE_COMMENTS . exec ( pathname ) ) ) return issueComments ( match [ 1 ] ! , Number ( match [ 2 ] ) ) ;
256259 // The dashboard filters by neither branch, so a stack's filtered lists are left to the API.
257- if ( ( match = OPEN_PULLS . exec ( pathname ) ) && searchParams . get ( "state" ) === "open" && ! searchParams . has ( "head" ) && ! searchParams . has ( "base" ) ) return openPulls ( match [ 1 ] ! , Number ( searchParams . get ( "per_page" ) ?? 30 ) <= DASHBOARD_PAGE ) ;
260+ if ( ( match = OPEN_PULLS . exec ( pathname ) ) && searchParams . get ( "state" ) === "open" && ! searchParams . has ( "head" ) ) return openPulls ( match [ 1 ] ! , Number ( searchParams . get ( "per_page" ) ?? 30 ) <= DASHBOARD_PAGE , searchParams . get ( "base" ) ) ;
258261 if ( ( match = CHECK_RUNS . exec ( pathname ) ) ) return checkRuns ( match [ 1 ] ! , match [ 2 ] ! ) ;
259262 if ( ( match = FOLDER . exec ( pathname ) ) && ! searchParams . has ( "ref" ) ) return folder ( match [ 1 ] ! , decodeURIComponent ( match [ 2 ] ?? "" ) ) ;
260263 return null ;
0 commit comments