Skip to content

Repository indicator improvements - #10119

Merged
niik merged 25 commits into
developmentfrom
repository-indicator-improvements
Sep 3, 2020
Merged

niik merged 25 commits into
developmentfrom
repository-indicator-improvements

Conversation

@niik

@niik niik commented Jul 1, 2020 •

Copy link
Copy Markdown
Member

Description

This is a work-in-progress PR with the intent of reviewing our current logic for repository indicators, improving upon it where necessary, and ultimately making the entire feature itself optional as per our Q1/H1 initiatives

In additional to general cleanup this PR does the following

  • Extracts all scheduling logic for refreshing repository sidebar indicators to RepositoryIndicatorUpdater
  • Ensures that we don't refresh repository sidebar indicators when the app is in the background
  • Gets rid of the simplistic setInterval in favor of a proper scheduler which can be paused and which will only schedule its next run after having refreshed all indicators (preventing the possibility of multiple concurrent refreshes if a refresh takes longer than the interval)
  • Defers loading of sidebar indicators on initial launch until 2 minutes post launch or the first time the user opens the repository sidebar
  • Prevents redundant double fetches when refreshing repository indicators by fixing a bug in inferLastPushForRepository
  • Removes inferLastPushForRepository's misplaced responsibility to ensure that we have an up-to-date lastFetched date for a repository

const shouldFetch = this.shouldPerformFetch(this.repository)
const shouldFetch = await this.shouldPerformFetch(this.repository)

if (this.stopped) {

@niik niik Aug 28, 2020 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Had to add this because of the newly introduced async call above. We could have been stopped in between calling that method and it returning.

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.

Nice catch!

@niik
niik marked this pull request as ready for review August 28, 2020 16:58
@niik
niik requested a review from rafeca August 28, 2020 16:58
rafeca
rafeca previously approved these changes Aug 31, 2020

@rafeca rafeca 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.

LGTM!

only thing thing to note is that this will cause the repository updater to run when focusing the application after long periods of inactivity, but I don't think that' an issue since the updater should be quite lightweight in terms of CPU usage (it's actually a nice feature, since we then make sure that we update the repos when the user actually wants to use Desktop and not during inactivity periods).

Comment thread app/src/lib/stores/git-store.ts Resolved
const shouldFetch = this.shouldPerformFetch(this.repository)
const shouldFetch = await this.shouldPerformFetch(this.repository)

if (this.stopped) {

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.

Nice catch!

@niik

niik commented Sep 2, 2020

Copy link
Copy Markdown
Member Author

only thing thing to note is that this will cause the repository updater to run when focusing the application after long periods of inactivity, but I don't think that' an issue since the updater should be quite lightweight in terms of CPU usage (it's actually a nice feature, since we then make sure that we update the repos when the user actually wants to use Desktop and not during inactivity periods).

Yeah, this is a tough change to make. We don't want to add much work on focus but the way we had it was pretty terrible where it would constantly fetch and call status in the background. I think this is a step in the right direction but we'll need more work here as well as an explicit opt-out (which will come in a later PR). Ideally I'd want to defer refresh on focus for a while but the logic is complex enough now that I'd rather way until we know it's a problem.

@niik
niik requested a review from rafeca September 2, 2020 15:09
@niik

niik commented Sep 2, 2020

Copy link
Copy Markdown
Member Author

@rafeca I made one additional change which was to not refresh repository indicators for the currently selected repository as that's redundant. We already refresh the current repo on focus.

@rafeca rafeca 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.

Awesome!

@niik
niik merged commit d7e7f60 into development Sep 3, 2020
@niik
niik deleted the repository-indicator-improvements branch September 3, 2020 09:25

@David8166 David8166 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Better

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants