Skip to content

Commit d8d49c6

Browse files
committed
Ensure repositories are only refreshed once when loading the repo list
1 parent b3221d0 commit d8d49c6

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

app/src/ui/repositories-list/repositories-list.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,17 @@ import { SectionFilterList } from '../lib/section-filter-list'
2727
import { assertNever } from '../../lib/fatal-error'
2828
import { IAheadBehind } from '../../models/branch'
2929
import { ShowBranchNameInRepoListSetting } from '../../models/show-branch-name-in-repo-list'
30+
import { throttle } from 'lodash'
3031

3132
const BlankSlateImage = encodePathAsUrl(__dirname, 'static/empty-no-repo.svg')
3233

34+
const refreshRepositoryThrottled = throttle(
35+
async (dispatcher: Dispatcher, repository: Repository) => {
36+
await dispatcher.refreshRepository(repository)
37+
},
38+
5000
39+
)
40+
3341
interface IRepositoriesListProps {
3442
readonly selectedRepository: Repositoryish | null
3543
readonly repositories: ReadonlyArray<Repositoryish>
@@ -180,7 +188,7 @@ export class RepositoriesList extends React.Component<
180188
item.repository
181189
)
182190
if (branchState.allBranches.length === 0) {
183-
this.props.dispatcher.refreshRepository(item.repository)
191+
refreshRepositoryThrottled(this.props.dispatcher, item.repository)
184192
return false
185193
}
186194
const defaultBranch = branchState.defaultBranch

0 commit comments

Comments
 (0)