Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Parallelize some more PR and review loading requests #1124

Merged
merged 1 commit into from
Oct 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions app/src/main/java/com/gh4a/activities/PullRequestActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
import java.util.Locale;

import io.reactivex.Single;
import io.reactivex.schedulers.Schedulers;

public class PullRequestActivity extends BaseFragmentPagerActivity implements
View.OnClickListener, ConfirmationDialogFragment.Callback,
Expand Down Expand Up @@ -497,11 +498,13 @@ private void load(boolean force) {
IssueService issueService = ServiceFactory.get(IssueService.class, force);

Single<PullRequest> prSingle = prService.getPullRequest(mRepoOwner, mRepoName, mPullRequestNumber)
.map(ApiHelpers::throwOnFailure);
.map(ApiHelpers::throwOnFailure)
.subscribeOn(Schedulers.io());
Single<Issue> issueSingle = issueService.getIssue(mRepoOwner, mRepoName, mPullRequestNumber)
.map(ApiHelpers::throwOnFailure);
Single<Boolean> isCollaboratorSingle =
SingleFactory.isAppUserRepoCollaborator(mRepoOwner, mRepoName, force);
.map(ApiHelpers::throwOnFailure)
.subscribeOn(Schedulers.io());
Single<Boolean> isCollaboratorSingle = SingleFactory.isAppUserRepoCollaborator(mRepoOwner, mRepoName, force)
.subscribeOn(Schedulers.io());

Single.zip(issueSingle, prSingle, isCollaboratorSingle, Triplet::create)
.compose(makeLoaderSingle(0, force))
Expand Down
7 changes: 6 additions & 1 deletion app/src/main/java/com/gh4a/fragment/ReviewFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import java.util.List;

import io.reactivex.Single;
import io.reactivex.schedulers.Schedulers;
import retrofit2.Response;

public class ReviewFragment extends ListDataBaseFragment<TimelineItem> implements
Expand Down Expand Up @@ -204,7 +205,11 @@ protected Single<List<TimelineItem>> onCreateDataSingle(boolean bypassCache) {
.map(Optional::of);
});

return Single.zip(reviewItemSingle, reviewCommentsSingle, filesSingle, commentsSingle,
return Single.zip(
reviewItemSingle.subscribeOn(Schedulers.io()),
reviewCommentsSingle.subscribeOn(Schedulers.io()),
filesSingle.subscribeOn(Schedulers.io()),
commentsSingle.subscribeOn(Schedulers.io()),
(reviewItem, reviewComments, filesOpt, commentsOpt) -> {
if (!reviewComments.isEmpty()) {
HashMap<String, GitHubFile> filesByName = new HashMap<>();
Expand Down