@@ -171,6 +171,7 @@ export function PullRequestsPage() {
171171 selectedProject,
172172 queryEnvironmentIds,
173173 environmentQueries,
174+ preferredEnvironmentQueries,
174175 assignmentKey,
175176 linkedSelection,
176177 expectedHosts,
@@ -316,47 +317,51 @@ export function PullRequestsPage() {
316317 } ) ;
317318 }
318319
319- const listTargets = environmentQueries . flatMap ( ( { environmentId, projectIds } ) => {
320- const cursors = sentCursors ?. [ environmentId ] ;
321- if ( sentCursors !== null && cursors === undefined && ! sentRegrown . includes ( environmentId ) ) {
322- return [ ] ;
323- }
324- return [
325- {
326- environmentId,
327- input : {
328- state : search . state ,
329- involvement : search . involvement ,
330- limit : pageSize ,
331- ...( scopedProjectId ? { projectId : scopedProjectId } : { } ) ,
332- ...( projectIds ? { projectIds } : { } ) ,
333- ...( search . host ? { host : search . host } : { } ) ,
334- ...( hasFilters ? { filters } : { } ) ,
335- ...( sentParsed . text ? { query : sentParsed . text } : { } ) ,
336- ...( cursors === undefined ? { } : { cursors } ) ,
337- } satisfies PullRequestListInput ,
338- } ,
339- ] ;
340- } ) ;
320+ const listTargetsFor = ( queries : typeof environmentQueries ) =>
321+ queries . flatMap ( ( { environmentId, projectIds } ) => {
322+ const cursors = sentCursors ?. [ environmentId ] ;
323+ if ( sentCursors !== null && cursors === undefined && ! sentRegrown . includes ( environmentId ) ) {
324+ return [ ] ;
325+ }
326+ return [
327+ {
328+ environmentId,
329+ input : {
330+ state : search . state ,
331+ involvement : search . involvement ,
332+ limit : pageSize ,
333+ ...( scopedProjectId ? { projectId : scopedProjectId } : { } ) ,
334+ ...( projectIds ? { projectIds } : { } ) ,
335+ ...( search . host ? { host : search . host } : { } ) ,
336+ ...( hasFilters ? { filters } : { } ) ,
337+ ...( sentParsed . text ? { query : sentParsed . text } : { } ) ,
338+ ...( cursors === undefined ? { } : { cursors } ) ,
339+ } satisfies PullRequestListInput ,
340+ } ,
341+ ] ;
342+ } ) ;
343+ const listTargets = listTargetsFor ( environmentQueries ) ;
341344 const listQuery = usePullRequestList ( listTargets ) ;
342345
343346 /**
344347 * Kept as its own read rather than remembered from an earlier answer because an answer cannot
345348 * say which question it belongs to: mid-switch the text has already changed and the data has
346349 * not, and a search's answer would file itself under the workspace.
347350 */
348- const baselineTargets = environmentQueries . map ( ( { environmentId, projectIds } ) => ( {
349- environmentId,
350- input : {
351- state : search . state ,
352- involvement : search . involvement ,
353- limit : PAGE_SIZE ,
354- ...( scopedProjectId ? { projectId : scopedProjectId } : { } ) ,
355- ...( projectIds ? { projectIds } : { } ) ,
356- ...( search . host ? { host : search . host } : { } ) ,
357- ...( menuFiltered ? { filters : menuFilters } : { } ) ,
358- } satisfies PullRequestListInput ,
359- } ) ) ;
351+ const baselineTargetsFor = ( queries : typeof environmentQueries ) =>
352+ queries . map ( ( { environmentId, projectIds } ) => ( {
353+ environmentId,
354+ input : {
355+ state : search . state ,
356+ involvement : search . involvement ,
357+ limit : PAGE_SIZE ,
358+ ...( scopedProjectId ? { projectId : scopedProjectId } : { } ) ,
359+ ...( projectIds ? { projectIds } : { } ) ,
360+ ...( search . host ? { host : search . host } : { } ) ,
361+ ...( menuFiltered ? { filters : menuFilters } : { } ) ,
362+ } satisfies PullRequestListInput ,
363+ } ) ) ;
364+ const baselineTargets = baselineTargetsFor ( environmentQueries ) ;
360365 const baselineQuery = usePullRequestList ( baselineTargets ) ;
361366 const observedHosts = rememberPullRequestHosts (
362367 rememberPullRequestHosts ( hostReads , baselineQuery . observations ) ,
@@ -908,7 +913,10 @@ export function PullRequestsPage() {
908913 await Promise . all (
909914 queryEnvironmentIds . map ( ( environmentId ) => invalidate ( { environmentId, input : { } } ) ) ,
910915 ) ;
911- listQuery . refresh ( [ ...listTargets , ...baselineTargets ] ) ;
916+ listQuery . refresh ( [
917+ ...listTargetsFor ( preferredEnvironmentQueries ) ,
918+ ...baselineTargetsFor ( preferredEnvironmentQueries ) ,
919+ ] ) ;
912920 setHostReads ( resetPullRequestHosts ) ;
913921 setInvalidating ( false ) ;
914922 refreshListAndStats ( requestedStatsScope ) ;
0 commit comments