Skip to content

Commit 9880cb7

Browse files
committed
Optimize CountriesCell to add rows only when the cell loads
1 parent 98d5b77 commit 9880cb7

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

WordPress/Classes/ViewRelated/Stats/Period Stats/Countries/CountriesCell.swift

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ class CountriesCell: StatsBaseCell, NibLoadable {
2121
private typealias Style = WPStyleGuide.Stats
2222
private var forDetails = false
2323

24+
override func awakeFromNib() {
25+
super.awakeFromNib()
26+
27+
addDefaultTotalRows(toStackView: rowsStackView)
28+
}
29+
2430
// MARK: - Configure
2531

2632
func configure(itemSubtitle: String,
@@ -38,21 +44,27 @@ class CountriesCell: StatsBaseCell, NibLoadable {
3844
bottomSeparatorLine.isHidden = forDetails
3945

4046
if !forDetails {
41-
addRows(dataRows,
42-
toStackView: rowsStackView,
47+
if rowsStackView.arrangedSubviews.isEmpty {
48+
addDefaultTotalRows(toStackView: rowsStackView)
49+
}
50+
configureTotalRows(
51+
dataRows,
52+
inStackView: rowsStackView,
4353
forType: .period,
44-
limitRowsDisplayed: true,
45-
viewMoreDelegate: self)
54+
configuration: .init(
55+
limitRowsDisplayed: true,
56+
rowDelegate: nil,
57+
referrerDelegate: nil,
58+
viewMoreDelegate: self
59+
)
60+
)
61+
} else {
62+
removeRowsFromStackView(rowsStackView)
4663
}
4764

4865
setSubtitleVisibility()
4966
applyStyles()
5067
}
51-
52-
override func prepareForReuse() {
53-
super.prepareForReuse()
54-
removeRowsFromStackView(rowsStackView)
55-
}
5668
}
5769

5870
private extension CountriesCell {

0 commit comments

Comments
 (0)