Avoid fetching changed file in order to load PR conversations #1174
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In order to load the PR conversation, the app fetches also all the files that have been changed in the PR.
The data related to changed files is used only by the "View in file" menu action, which is available only for review comments that are not outdated. Since those comments are displayed in the review details screen and not in the conversation (except in one case, explained below), fetching that data is unnecessary in order to load the conversation.
This optimization greatly speeds up conversation loading for PRs which have lots of changed files, such as k0shk0sh/FastHub#2599. Another extreme example is topjohnwu/Magisk#5134 which has something like 5000 changed files which take minutes to be fetched.
There is only one thing that we lose by not fetching changed files anymore: single review comments created before the introduction of reviews by GitHub - like the ones found in rails/rails#21045 - get displayed in between the conversation, and before this PR they would have had the "View in file" menu action if they weren't outdated.
I think that the optimization - which applies to all PRs - is well worth the very small loss in functionality for a subset of those old, "special" comments.
I've also added some explanatory comments to the
PullRequestConversationFragment
and changed theReviewFragment
to avoid re-fetching theReview
object, since it gets already passed via intent extras.