Repository navigation
Check API for updates before fetching - #5320
Conversation
| return | ||
| } | ||
|
|
||
| const account = getAccountForRepository(this.accounts, repository) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This info is available from the git store
Passing the last push allows me to control how and when I get the last push date
shiftkey
left a comment
There was a problem hiding this comment.
I like where this is heading, but before I go and try and break this code here's some initial feedback
|
|
||
| return true | ||
| // we should fetch if the last push happened after the last fetch | ||
| const shouldFetch = lastPush !== undefined ? lastFetched < lastPush : true |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| let lastPush: Date | undefined | ||
| const account = getAccountForRepository(this.accounts, repository) | ||
| if (account !== null && repository.gitHubRepository) { | ||
| // NOTE: does this look at if your current branch is tracking a different remote |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
💯 Tested with my local repos. Note, I had to modify the following locally to test: desktop/app/src/lib/stores/app-store.ts Lines 1938 to 1945 in 7e17011 Updated that number to 25 (I have 21 local repos) Line 98 in 7e17011 Updated to refresh every minute. |
| const now = new Date() | ||
| const timeSinceFetch = now.getTime() - lastFetched.getTime() | ||
|
|
||
| const repoName = |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| * @param gitStore Git information about the repository | ||
| * @param repository the local repository tracked by Desktop | ||
| */ | ||
| private async inferLastPushForRepository( |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| } | ||
|
|
||
| if (repository.gitHubRepository !== null) { | ||
| const api = API.fromAccount(account) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| } | ||
|
|
||
| // we should fetch if the last push happened after the last fetch | ||
| const shouldFetch = lastFetched < lastPush |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| gitStore, | ||
| repository | ||
| ) | ||
| if (this.shouldBackgroundFetch(repo, lastPush)) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| await gitStore.updateLastFetched() | ||
|
|
||
| if (this.shouldBackgroundFetch(repository, lastPush)) { | ||
| await gitStore.loadRemotes() |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
|
||
| log.debug( | ||
| `Skipping background fetch since nothing has been pushed to '${repoName}' since the last fetch at ${new Date( | ||
| lastFetched |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| account, | ||
| r => this.performFetch(r, account, FetchType.BackgroundTask), | ||
| r => this.shouldBackgroundFetch(r) | ||
| r => this.shouldBackgroundFetch(r, null) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
💯 |
|
Going to merge this in early because I want to build upon these changes 🏎 |
Fixes #5312
Related discussion: #1252