diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index 54aa44bdc91..db3825ef15f 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -3,6 +3,7 @@ 22.7 ----- +- [*] Order Details: Fix crash when reloading data [https://github.com/woocommerce/woocommerce-ios/pull/15764] - [*] Shipping Labels: Improved shipment management UI by hiding remove/merge options instead of disabling them, hiding merge option for orders with 2 or fewer unfulfilled shipments, and hiding the ellipsis menu when no remove/merge actions are available [https://github.com/woocommerce/woocommerce-ios/pull/15760] - [**] POS: a POS tab in the tab bar is now available in the app for stores eligible for Point of Sale, instead of the previous entry point in the Menu tab. [https://github.com/woocommerce/woocommerce-ios/pull/15766] diff --git a/WooCommerce/Classes/ViewModels/Order Details/OrderDetailsDataSource.swift b/WooCommerce/Classes/ViewModels/Order Details/OrderDetailsDataSource.swift index 57a29ff0f54..045dc977bfc 100644 --- a/WooCommerce/Classes/ViewModels/Order Details/OrderDetailsDataSource.swift +++ b/WooCommerce/Classes/ViewModels/Order Details/OrderDetailsDataSource.swift @@ -136,27 +136,23 @@ final class OrderDetailsDataSource: NSObject { /// Order shipment tracking list /// - var orderTracking: [ShipmentTracking] { - return resultsControllers.orderTracking - } + var orderTracking: [ShipmentTracking] = [] /// Order statuses list /// - var currentSiteStatuses: [OrderStatus] { - return resultsControllers.currentSiteStatuses - } + var currentSiteStatuses: [OrderStatus] = [] /// Products from an Order /// - var products: [Product] { - return resultsControllers.products - } + var products: [Product] = [] + + /// Product variations from an order + /// + var productVariations: [ProductVariation] = [] /// Custom amounts (fees) from an Order /// - var customAmounts: [OrderFeeLine] { - return resultsControllers.feeLines - } + var customAmounts: [OrderFeeLine] = [] /// OrderItemsRefund Count /// @@ -166,19 +162,13 @@ final class OrderDetailsDataSource: NSObject { /// Refunds on an Order /// - var refunds: [Refund] { - return resultsControllers.refunds - } + var refunds: [Refund] = [] - var addOnGroups: [AddOnGroup] { - resultsControllers.addOnGroups - } + var addOnGroups: [AddOnGroup] = [] /// Shipping Methods list /// - var siteShippingMethods: [ShippingMethod] { - resultsControllers.siteShippingMethods - } + var siteShippingMethods: [ShippingMethod] = [] /// Shipping Labels for an Order /// @@ -1171,7 +1161,7 @@ extension OrderDetailsDataSource { } private func lookUpProductVariation(productID: Int64, variationID: Int64) -> ProductVariation? { - return resultsControllers.productVariations.filter({ $0.productID == productID && $0.productVariationID == variationID }).first + return productVariations.filter({ $0.productID == productID && $0.productVariationID == variationID }).first } func lookUpRefund(by refundID: Int64) -> Refund? { @@ -1195,12 +1185,20 @@ extension OrderDetailsDataSource { @MainActor func reloadSections() async { // Freezes any data that require lookup after the sections are reloaded, in case the data from a ResultsController changes before the next reload. + refunds = resultsControllers.refunds + customAmounts = resultsControllers.feeLines + orderTracking = resultsControllers.orderTracking + currentSiteStatuses = resultsControllers.currentSiteStatuses + products = resultsControllers.products + addOnGroups = resultsControllers.addOnGroups + siteShippingMethods = resultsControllers.siteShippingMethods + productVariations = resultsControllers.productVariations shippingLabels = resultsControllers.shippingLabels shippingLabelOrderItemsAggregator = AggregatedShippingLabelOrderItems( shippingLabels: shippingLabels, orderItems: items, products: products, - productVariations: resultsControllers.productVariations + productVariations: productVariations ) var sections = buildStaticSections().compactMap { $0 }