Skip to content

Commit 2006337

Browse files
committed
14869 Declare refreshable modifiers on list views
Previously we had to put our refreshable modifiers higher in the heirarchy than the views they were refreshing, because we changed the state to `loading` when we pulled to refresh. This change of state cancelled the pull to refresh network task. The state change for refresh was removed in 01cfd95fbd01e45e4a63982390787ab00bd15e84, and now we can group the refreshable control more closely with the list view it relates to.
1 parent 8ff6a47 commit 2006337

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

WooCommerce/Classes/POS/Presentation/Item Selector/ChildItemList.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ private extension ChildItemList {
6767
ItemList(state: state,
6868
node: .parent(parentItem))
6969
.transition(.opacity)
70+
.refreshable {
71+
ServiceLocator.analytics.track(.pointOfSaleVariationsPullToRefresh)
72+
await posModel.refreshItems(base: .parent(parentItem))
73+
}
7074
}
7175
}
7276

WooCommerce/Classes/POS/Presentation/ItemListView.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,17 +138,17 @@ private extension ItemListView {
138138
bannerCardView
139139
}
140140
}
141+
.refreshable {
142+
ServiceLocator.analytics.track(.pointOfSaleProductsPullToRefresh)
143+
await posModel.refreshItems(base: .root)
144+
}
141145
}
142146

143147
@ViewBuilder
144148
func childListView(parentItem: POSItem) -> some View {
145149
switch parentItem {
146150
case let .variableParentProduct(parentProduct):
147151
ChildItemList(parentItem: parentItem, title: parentProduct.name)
148-
.refreshable {
149-
ServiceLocator.analytics.track(.pointOfSaleVariationsPullToRefresh)
150-
await posModel.refreshItems(base: .parent(parentItem))
151-
}
152152
default:
153153
EmptyView()
154154
}

WooCommerce/Classes/POS/Presentation/PointOfSaleDashboardView.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,6 @@ struct PointOfSaleDashboardView: View {
8888
HStack {
8989
if posModel.orderStage == .building {
9090
ItemListView()
91-
.refreshable {
92-
ServiceLocator.analytics.track(.pointOfSaleProductsPullToRefresh)
93-
await posModel.refreshItems(base: .root)
94-
}
9591
.accessibilitySortPriority(2)
9692
.transition(.move(edge: .leading))
9793
}

0 commit comments

Comments
 (0)