Skip to content

Commit dc7f0dc

Browse files
committed
Freeze product variations
1 parent a308394 commit dc7f0dc

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

WooCommerce/Classes/ViewModels/Order Details/OrderDetailsDataSource.swift

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,10 @@ final class OrderDetailsDataSource: NSObject {
146146
///
147147
var products: [Product] = []
148148

149+
/// Product variations from an order
150+
///
151+
var productVariations: [ProductVariation] = []
152+
149153
/// Custom amounts (fees) from an Order
150154
///
151155
var customAmounts: [OrderFeeLine] = []
@@ -1157,7 +1161,7 @@ extension OrderDetailsDataSource {
11571161
}
11581162

11591163
private func lookUpProductVariation(productID: Int64, variationID: Int64) -> ProductVariation? {
1160-
return resultsControllers.productVariations.filter({ $0.productID == productID && $0.productVariationID == variationID }).first
1164+
return productVariations.filter({ $0.productID == productID && $0.productVariationID == variationID }).first
11611165
}
11621166

11631167
func lookUpRefund(by refundID: Int64) -> Refund? {
@@ -1181,20 +1185,21 @@ extension OrderDetailsDataSource {
11811185
@MainActor
11821186
func reloadSections() async {
11831187
// Freezes any data that require lookup after the sections are reloaded, in case the data from a ResultsController changes before the next reload.
1184-
shippingLabels = resultsControllers.shippingLabels
1185-
shippingLabelOrderItemsAggregator = AggregatedShippingLabelOrderItems(
1186-
shippingLabels: shippingLabels,
1187-
orderItems: items,
1188-
products: products,
1189-
productVariations: resultsControllers.productVariations
1190-
)
11911188
refunds = resultsControllers.refunds
11921189
customAmounts = resultsControllers.feeLines
11931190
orderTracking = resultsControllers.orderTracking
11941191
currentSiteStatuses = resultsControllers.currentSiteStatuses
11951192
products = resultsControllers.products
11961193
addOnGroups = resultsControllers.addOnGroups
11971194
siteShippingMethods = resultsControllers.siteShippingMethods
1195+
productVariations = resultsControllers.productVariations
1196+
shippingLabels = resultsControllers.shippingLabels
1197+
shippingLabelOrderItemsAggregator = AggregatedShippingLabelOrderItems(
1198+
shippingLabels: shippingLabels,
1199+
orderItems: items,
1200+
products: products,
1201+
productVariations: productVariations
1202+
)
11981203

11991204
var sections = buildStaticSections().compactMap { $0 }
12001205
let paymentSection = await createPaymentSection()

0 commit comments

Comments
 (0)