Fix pull request list not updating #11241
Merged
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.
Description
I noticed recently that the PR list for a repository was missing the most recent PR or two. It only happened intermittently but I was recently able to reproduce it and found that due to a bug in the
PullRequestCoordinator
(which has been there since the beginning) it would fail to emit an update when the PR list for a repository changed. Story time.In #11063 we significantly reduced the number of times the repository store emits an update signaling to the rest of the app that the list of repositories has changed (i.e. a repository was added, removed, or its information was updated). See e14db86#diff-efb525e0e38f508020a700c360ea248af1b2a6f0c5cb44f728830acbecbccbe3 for one such example.
When the
PullRequestStore
refreshes the list of PRs for a repository it emits an eventdesktop/app/src/lib/stores/pull-request-store.ts
Line 221 in cf603e8
Which is then caught by the
PullRequestCoordinator
which figures out whichRepository
models needs to be updated as a result of the PR Store refreshing PRs for aGitHubRepository
(severalRepository
models may share the sameGitHubRepository
either by being duplicate clones of the same repository or by one being a forked repo and the other being the parent).desktop/app/src/lib/stores/pull-request-coordinator.ts
Lines 82 to 96 in cf603e8
The problem here turned out to be that
this.repositories
was an empty array. Therepositories
field is updated whenever theRepositoriesStore
emits an update:desktop/app/src/lib/stores/pull-request-coordinator.ts
Lines 50 to 60 in cf603e8
And here's the crux of the issue. Since #11063 made it that much rarer for the
RepositoriesStore
to emit an update you would need something to happen (add/remove/change a repository) before thePullRequestCoordinator
kicked into gear and started forwarding these events properly.I've addressed this by ensuring that the list of repositories is loaded when the coordinator initiates. I've also fixed a minor bug that I happened to note while debugging this where a non-primitive object (repo.owner) was coerced into a string in order to form the equality comparison hash.
Release notes
Notes: [Fixed] Addressed an issue where pull requests could fail to update until the user switched repositories