Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 432000a

Browse files
committed
Extract logic into method selectFirstNonEmptyList for clarity
1 parent b6a9a49 commit 432000a

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

lib/views/composite-list-selection.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,7 @@ export default class CompositeListSelection {
1414
this.selections.push(selection)
1515
}
1616

17-
this.activeSelectionIndex = 0
18-
for (var i = 0; i < this.selections.length; i++) {
19-
if (this.selections[i].getItems().length) {
20-
this.activeSelectionIndex = i
21-
break
22-
}
23-
}
17+
this.selectFirstNonEmptyList()
2418
}
2519

2620
updateLists (listsByKey) {
@@ -38,6 +32,16 @@ export default class CompositeListSelection {
3832
}
3933
}
4034

35+
selectFirstNonEmptyList () {
36+
this.activeSelectionIndex = 0
37+
for (var i = 0; i < this.selections.length; i++) {
38+
if (this.selections[i].getItems().length) {
39+
this.activeSelectionIndex = i
40+
break
41+
}
42+
}
43+
}
44+
4145
getActiveListKey () {
4246
return this.keysBySelection.get(this.getActiveSelection())
4347
}

0 commit comments

Comments
 (0)