@@ -27,17 +27,9 @@ import { SectionFilterList } from '../lib/section-filter-list'
2727import { assertNever } from '../../lib/fatal-error'
2828import { IAheadBehind } from '../../models/branch'
2929import { ShowBranchNameInRepoListSetting } from '../../models/show-branch-name-in-repo-list'
30- import { throttle } from 'lodash'
3130
3231const BlankSlateImage = encodePathAsUrl ( __dirname , 'static/empty-no-repo.svg' )
3332
34- const refreshRepositoryThrottled = throttle (
35- async ( dispatcher : Dispatcher , repository : Repository ) => {
36- await dispatcher . refreshRepository ( repository )
37- } ,
38- 5000
39- )
40-
4133interface IRepositoriesListProps {
4234 readonly selectedRepository : Repositoryish | null
4335 readonly repositories : ReadonlyArray < Repositoryish >
@@ -169,33 +161,19 @@ export class RepositoriesList extends React.Component<
169161
170162 private shouldShowBranchName ( item : IRepositoryListItem ) : boolean {
171163 const { showBranchNameInRepoList } = this . props
172-
173- if ( ! ( item . repository instanceof Repository ) || ! item . branchName ) {
174- return false
175- }
176- if ( showBranchNameInRepoList === ShowBranchNameInRepoListSetting . Never ) {
177- return false
178- }
179- if ( showBranchNameInRepoList === ShowBranchNameInRepoListSetting . Always ) {
180- return true
181- }
182-
183- if (
184- showBranchNameInRepoList ===
185- ShowBranchNameInRepoListSetting . WhenNotDefault
186- ) {
187- const branchState = this . props . dispatcher . getBranchesState (
188- item . repository
189- )
190- if ( branchState . allBranches . length === 0 ) {
191- refreshRepositoryThrottled ( this . props . dispatcher , item . repository )
164+ switch ( showBranchNameInRepoList ) {
165+ case ShowBranchNameInRepoListSetting . Never :
192166 return false
193- }
194- const defaultBranch = branchState . defaultBranch
195- return defaultBranch === null || item . branchName !== defaultBranch . name
167+ case ShowBranchNameInRepoListSetting . Always :
168+ return true
169+ case ShowBranchNameInRepoListSetting . WhenNotDefault :
170+ return item . branchName !== item . defaultBranchName
171+ default :
172+ assertNever (
173+ showBranchNameInRepoList ,
174+ `Unknown show branch name setting: ${ showBranchNameInRepoList } `
175+ )
196176 }
197-
198- assertNever ( showBranchNameInRepoList , `Unknown show branch name setting` )
199177 }
200178
201179 private renderItem = ( item : IRepositoryListItem , matches : IMatches ) => {
@@ -208,9 +186,7 @@ export class RepositoriesList extends React.Component<
208186 matches = { matches }
209187 aheadBehind = { item . aheadBehind }
210188 changedFilesCount = { item . changedFilesCount }
211- branchName = {
212- this . shouldShowBranchName ( item ) ? item . branchName : undefined
213- }
189+ branchName = { this . shouldShowBranchName ( item ) ? item . branchName : null }
214190 />
215191 )
216192 }
@@ -239,9 +215,7 @@ export class RepositoriesList extends React.Component<
239215 item : IRepositoryListItem
240216 ) : JSX . Element | string | null => {
241217 const { repository, aheadBehind, changedFilesCount } = item
242- const branchName = this . shouldShowBranchName ( item )
243- ? item . branchName
244- : undefined
218+ const branchName = this . shouldShowBranchName ( item ) ? item . branchName : null
245219 const gitHubRepo =
246220 repository instanceof Repository ? repository . gitHubRepository : null
247221 const alias = repository instanceof Repository ? repository . alias : null
0 commit comments