Skip to content

[Fork] Initial PullRequestCoordinator (P)refactor - #8825

Merged
outofambit merged 30 commits into
developmentfrom
chore/pull-request-coordinator
Jan 9, 2020
Merged

outofambit merged 30 commits into
developmentfrom
chore/pull-request-coordinator

Conversation

@outofambit

@outofambit outofambit commented Dec 20, 2019 •

Copy link
Copy Markdown
Contributor

supports #8549

Background

While discussing #8652, @niik and I agreed we needed an layer between AppStore and the workings of PullRequestStore and PullRequestUpdater. These relatively simple classes were getting bloated with additional logic and it felt like it would be easier to manage if there was something to contain that logic, outside of AppStore.

Description

This pull request begins this work by introducing this layer as PullRequestCoordinator (at least that's what I'm calling it for now) but retaining the current application's behavior.

Small Changes

One notable change is that the PullRequestCoordinator communicates with the AppStore in reference to a Repository, not a GitHubRepository as it did previously. This small but significant change will allow the PullRequestCoordinator to compartmentalize concerns around matching remote GitHub repositories with local repositories.

AppStore manages state for a single "selected" repository (the one currently in view in the UI), so this is a better fit for AppStore's concerns regardless.

Next Steps

Further changes to close #8549 will happen in future pull requests. They vast majority of these changes should be contained within the new PullRequestCoordinator.

@outofambit
outofambit force-pushed the chore/pull-request-coordinator branch from d5244af to d20dc9a Compare January 2, 2020 19:53
Comment on lines +81 to +83
export type RepositoryWithGitHubRepository = Repository & {
readonly gitHubRepository: GitHubRepository
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One potentially controversial thing I've done is add a RepositoryWithGitHubRepository type which guarantees a Repository model has a GitHubRepository model in it. I did this primarily to make the null checks a little easier to read, since the PullRequestCoordinator is only be concerned with repositories that are connected to GitHub somehow, while AppStore and RepositoriesStore are concerned with all local repositories. This is kind of a band-aid for our domain model but that's a (long) story for another day.

@outofambit
outofambit marked this pull request as ready for review January 2, 2020 20:43
@outofambit
outofambit requested review from niik and tierninho January 2, 2020 20:43
@tierninho tierninho changed the title Initial PullRequestCoordinator (P)refactor [Fork] Initial PullRequestCoordinator (P)refactor Jan 7, 2020
tierninho
tierninho previously approved these changes Jan 8, 2020

@tierninho tierninho left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tentative 👍 based on initial testing. Will continue exploratory testing on this in case there are any edge cases.

Majority of testing was done around the following:

  • Loading of PRs on initial launch and as repo fetches over time
  • Reliability of the PR refresh button
  • Scouting for errors in background updating for PRs

niik
niik previously requested changes Jan 9, 2020

@niik niik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great @outofambit, just one small question but overall this looks like a great prefactor.


private startPullRequestUpdater(repository: Repository) {
if (this.currentPullRequestUpdater) {
this.stopPullRequestUpdater()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removal of this stop operation from the startPullRequestUpdater method makes me a teeny bit nervous. I can' point towards anything that will break by removing this but given that pullRequestCoordinator.stopPullRequestUpdater is both cheap and idempotent could we maintain the current behavior just to be safe?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah I see. even though we do this in PullRequestCoordinator.startPullRequestUpdater, it might not get called! fixed in 8fb41ce

this.stopPullRequestUpdater()
}

// We don't want to run the pull request updater when the app is in

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change for the comment above about maintaining existing behavior.

Suggested change
// We don't want to run the pull request updater when the app is in
this.stopPullRequestUpdater()
// We don't want to run the pull request updater when the app is in

@niik niik self-assigned this Jan 9, 2020
@outofambit

Copy link
Copy Markdown
Contributor Author

Addressed @niik's concerns, going to merge so I can get the next PR in this series ready for review

@outofambit
outofambit merged commit f0aeabc into development Jan 9, 2020
@outofambit
outofambit deleted the chore/pull-request-coordinator branch January 17, 2020 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Fork] "Create pull request" is still a suggestion even after I've created a PR for the current branch on my fork

3 participants