Skip to content

Commit c5588c8

Browse files
committed
OrderDetailsViewController: Preventing (full) reload during Billing toggle
1 parent fd81274 commit c5588c8

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

WooCommerce/Classes/ViewRelated/Orders/OrderDetails/OrderDetailsViewController.swift

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ class OrderDetailsViewController: UIViewController {
1414
var viewModel: OrderDetailsViewModel! {
1515
didSet {
1616
reloadSections()
17+
reloadTableViewIfPossible()
1718
}
1819
}
1920
private var orderNotes: [OrderNoteViewModel]? {
2021
didSet {
2122
reloadSections()
23+
reloadTableViewIfPossible()
2224
}
2325
}
2426

@@ -27,15 +29,8 @@ class OrderDetailsViewController: UIViewController {
2729
reloadSections()
2830
}
2931
}
30-
private var sections = [Section]() {
31-
didSet {
32-
guard isViewLoaded else {
33-
return
34-
}
32+
private var sections = [Section]()
3533

36-
tableView.reloadData()
37-
}
38-
}
3934

4035
// MARK: - View Lifecycle
4136

@@ -108,6 +103,16 @@ private extension OrderDetailsViewController {
108103
}
109104
}
110105

106+
/// Reloads the tableView, granted that the view has been effectively loaded.
107+
///
108+
func reloadTableViewIfPossible() {
109+
guard isViewLoaded else {
110+
return
111+
}
112+
113+
tableView.reloadData()
114+
}
115+
111116
/// Registers all of the available TableViewCells
112117
///
113118
func registerTableViewCells() {

0 commit comments

Comments
 (0)