@@ -20,7 +20,7 @@ import { Repository, RefType, UpstreamRef } from '../api/api';
2020import Logger from '../common/logger' ;
2121import { EXTENSION_ID } from '../constants' ;
2222import { fromPRUri } from '../common/uri' ;
23- import { convertRESTPullRequestToRawPullRequest , convertPullRequestsGetCommentsResponseItemToComment , convertIssuesCreateCommentResponseToComment , parseGraphQLTimelineEvents , convertRESTTimelineEvents , getRelatedUsersFromTimelineEvents , parseGraphQLComment , getReactionGroup , convertRESTUserToAccount , convertRESTReviewEvent , parseGraphQLReviewEvent } from './utils' ;
23+ import { convertRESTPullRequestToRawPullRequest , convertPullRequestsGetCommentsResponseItemToComment , convertIssuesCreateCommentResponseToComment , parseGraphQLTimelineEvents , convertRESTTimelineEvents , getRelatedUsersFromTimelineEvents , parseGraphQLComment , getReactionGroup , convertRESTUserToAccount , convertRESTReviewEvent , parseGraphQLReviewEvent , loginComparator } from './utils' ;
2424import { PendingReviewIdResponse , TimelineEventsResponse , PullRequestCommentsResponse , AddCommentResponse , SubmitReviewResponse , DeleteReviewResponse , EditCommentResponse , DeleteReactionResponse , AddReactionResponse , MarkPullRequestReadyForReviewResponse , PullRequestState } from './graphql' ;
2525import { ITelemetry } from '../common/telemetry' ;
2626import { ApiImpl } from '../api/api1' ;
@@ -114,6 +114,8 @@ export class PullRequestManager implements vscode.Disposable {
114114 private _allGitHubRemotes : Remote [ ] = [ ] ;
115115 private _mentionableUsers ?: { [ key : string ] : IAccount [ ] } ;
116116 private _fetchMentionableUsersPromise ?: Promise < { [ key : string ] : IAccount [ ] } > ;
117+ private _assignableUsers ?: { [ key : string ] : IAccount [ ] } ;
118+ private _fetchAssignableUsersPromise ?: Promise < { [ key : string ] : IAccount [ ] } > ;
117119 private _gitBlameCache : { [ key : string ] : string } = { } ;
118120 private _githubManager : GitHubManager ;
119121 private _repositoryPageInformation : Map < string , PageInformation > = new Map < string , PageInformation > ( ) ;
@@ -459,6 +461,7 @@ export class PullRequestManager implements vscode.Disposable {
459461 || ! oldRepositories . every ( oldRepo => this . _githubRepositories . some ( newRepo => newRepo . remote . equals ( oldRepo . remote ) ) ) ;
460462
461463 this . getMentionableUsers ( repositoriesChanged ) ;
464+ this . getAssignableUsers ( repositoriesChanged ) ;
462465 this . state = hasAuthenticated || ! activeRemotes . length ? PRManagerState . RepositoriesLoaded : PRManagerState . NeedsAuthentication ;
463466 return Promise . resolve ( ) ;
464467 } ) ;
@@ -493,6 +496,35 @@ export class PullRequestManager implements vscode.Disposable {
493496 return this . _fetchMentionableUsersPromise ;
494497 }
495498
499+ async getAssignableUsers ( clearCache ?: boolean ) : Promise < { [ key : string ] : IAccount [ ] } > {
500+ if ( clearCache ) {
501+ delete this . _assignableUsers ;
502+ }
503+
504+ if ( this . _assignableUsers ) {
505+ return this . _assignableUsers ;
506+ }
507+
508+ if ( ! this . _fetchAssignableUsersPromise ) {
509+ const cache : { [ key : string ] : IAccount [ ] } = { } ;
510+ return this . _fetchAssignableUsersPromise = new Promise ( ( resolve ) => {
511+ const promises = this . _githubRepositories . map ( async githubRepository => {
512+ const data = await githubRepository . getAssignableUsers ( ) ;
513+ cache [ githubRepository . remote . remoteName ] = data . sort ( loginComparator ) ;
514+ return ;
515+ } ) ;
516+
517+ Promise . all ( promises ) . then ( ( ) => {
518+ this . _assignableUsers = cache ;
519+ this . _fetchAssignableUsersPromise = undefined ;
520+ resolve ( cache ) ;
521+ } ) ;
522+ } ) ;
523+ }
524+
525+ return this . _fetchAssignableUsersPromise ;
526+ }
527+
496528 /**
497529 * Returns the remotes that are currently active, which is those that are important by convention (origin, upstream),
498530 * or the remotes configured by the setting githubPullRequests.remotes
0 commit comments