mirror of
https://github.com/reiyua/github-profile-trophy-reiyua-mirror.git
synced 2026-11-17 06:02:09 +11:00
Fix promises process
This commit is contained in:
parent
20908aff97
commit
f88e07535b
1 changed files with 4 additions and 8 deletions
|
|
@ -56,20 +56,16 @@ export class GithubApiService extends GithubRepository {
|
||||||
}
|
}
|
||||||
async requestUserInfo(username: string): Promise<UserInfo | ServiceError> {
|
async requestUserInfo(username: string): Promise<UserInfo | ServiceError> {
|
||||||
// Avoid to call others if one of them is null
|
// Avoid to call others if one of them is null
|
||||||
const repository = await this.requestUserRepository(username);
|
|
||||||
|
|
||||||
if (repository instanceof ServiceError) {
|
|
||||||
Logger.error(repository);
|
|
||||||
return repository;
|
|
||||||
}
|
|
||||||
|
|
||||||
const promises = Promise.allSettled([
|
const promises = Promise.allSettled([
|
||||||
|
this.requestUserRepository(username),
|
||||||
this.requestUserActivity(username),
|
this.requestUserActivity(username),
|
||||||
this.requestUserIssue(username),
|
this.requestUserIssue(username),
|
||||||
this.requestUserPullRequest(username),
|
this.requestUserPullRequest(username),
|
||||||
]);
|
]);
|
||||||
const [activity, issue, pullRequest] = await promises;
|
const [repository, activity, issue, pullRequest] = await promises;
|
||||||
const status = [
|
const status = [
|
||||||
|
repository.status,
|
||||||
activity.status,
|
activity.status,
|
||||||
issue.status,
|
issue.status,
|
||||||
pullRequest.status,
|
pullRequest.status,
|
||||||
|
|
@ -84,7 +80,7 @@ export class GithubApiService extends GithubRepository {
|
||||||
(activity as PromiseFulfilledResult<GitHubUserActivity>).value,
|
(activity as PromiseFulfilledResult<GitHubUserActivity>).value,
|
||||||
(issue as PromiseFulfilledResult<GitHubUserIssue>).value,
|
(issue as PromiseFulfilledResult<GitHubUserIssue>).value,
|
||||||
(pullRequest as PromiseFulfilledResult<GitHubUserPullRequest>).value,
|
(pullRequest as PromiseFulfilledResult<GitHubUserPullRequest>).value,
|
||||||
repository,
|
(repository as PromiseFulfilledResult<GitHubUserRepository>).value,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue