Skip to content

Commit

Permalink
Fix #1181, unable to add reviewers to description view
Browse files Browse the repository at this point in the history
  • Loading branch information
Rachel Macfarlane committed Jul 12, 2019
1 parent 65e3dfe commit 5479c4e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
3 changes: 1 addition & 2 deletions src/github/githubRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,12 +376,11 @@ export class GitHubRepository implements IGitHubRepository, vscode.Disposable {
}
});

ret.push(...result.data.repository.mentionableUsers.nodes.map((node: any) => {
ret.push(...result.data.repository.mentionableUsers.nodes.map(node => {
return {
login: node.login,
avatarUrl: node.avatarUrl,
name: node.name,
email: node.email,
url: node.url
};
}));
Expand Down
32 changes: 17 additions & 15 deletions src/github/pullRequestManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -431,39 +431,41 @@ export class PullRequestManager implements vscode.Disposable {
}
}

this.getMentionableUsers();
const repositoriesChanged = oldRepositories.length !== this._githubRepositories.length
|| !oldRepositories.every(oldRepo => this._githubRepositories.some(newRepo => newRepo.remote.equals(oldRepo.remote)));

this.getMentionableUsers(repositoriesChanged);
return Promise.resolve();
});
}

async getMentionableUsers(): Promise<{ [key: string]: IAccount[] }> {
async getMentionableUsers(clearCache?: boolean): Promise<{ [key: string]: IAccount[] }> {
if (clearCache) {
delete this._mentionableUsers;
}

if (this._mentionableUsers) {
return this._mentionableUsers;
}

if (!this._fetchMentionableUsersPromise) {
let cache: { [key: string]: IAccount[] } = {};
return this._fetchMentionableUsersPromise = new Promise((resolve) => {
let promises: Promise<void>[] = [];
this._githubRepositories.forEach(githubRepository => {
promises.push(new Promise<void>(async (res) => {
let data = await githubRepository.getMentionableUsers();
cache[githubRepository.remote.remoteName] = data;
res();
}));
const promises = this._githubRepositories.map(async githubRepository => {
const data = await githubRepository.getMentionableUsers();
cache[githubRepository.remote.remoteName] = data;
return;
});

Promise.all(promises).then(() => {
this._mentionableUsers = cache;
this._fetchMentionableUsersPromise = undefined;
resolve(cache);
});
});
}

return this._fetchMentionableUsersPromise.then(cache => {
this._mentionableUsers = cache;
this._fetchMentionableUsersPromise = undefined;
return this._mentionableUsers;
});
return this._fetchMentionableUsersPromise;
}

/**
Expand Down Expand Up @@ -556,7 +558,7 @@ export class PullRequestManager implements vscode.Disposable {
};
}));

results = results.sort((a,b)=> a.name.localeCompare(b.name));
results = results.sort((a, b) => a.name.localeCompare(b.name));

hasNextPage = !!result.headers.link && result.headers.link.indexOf('rel="next"') > -1;
page += 1;
Expand Down

0 comments on commit 5479c4e

Please sign in to comment.