diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index 72ec7ed3083..50b4a8777de 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -6,6 +6,7 @@ - [**] We added support for collecting in-person payments (including Tap To Pay) using Stripe Payment Gateway extension in the UK. [https://github.com/woocommerce/woocommerce-ios/pull/16287] - [*] Improve card payments onboarding error handling to show network errors correctly [https://github.com/woocommerce/woocommerce-ios/pull/16304] - [*] Authenticate the admin page automatically for sites with SSO enabled in custom fields, in-person payment setup, and editing tax rates flows. [https://github.com/woocommerce/woocommerce-ios/pull/16318] +- [*] Fix order details presentation when opened from booking details [https://github.com/woocommerce/woocommerce-ios/pull/16331] - [*] Show POS feedback surveys for eligible merchants [https://github.com/woocommerce/woocommerce-ios/pull/16325] 23.6 diff --git a/WooCommerce/Classes/ViewRelated/Orders/Order Details/OrderDetailsViewController.swift b/WooCommerce/Classes/ViewRelated/Orders/Order Details/OrderDetailsViewController.swift index c749ee1efc1..a9819af346e 100644 --- a/WooCommerce/Classes/ViewRelated/Orders/Order Details/OrderDetailsViewController.swift +++ b/WooCommerce/Classes/ViewRelated/Orders/Order Details/OrderDetailsViewController.swift @@ -110,6 +110,14 @@ final class OrderDetailsViewController: UIViewController { override var shouldShowOfflineBanner: Bool { true } + + func isPresentingViewModelOrder(_ viewModel: OrderDetailsViewModel) -> Bool { + return self.viewModel.order.orderID == viewModel.order.orderID + } + + func isQuickOrderNavigationSupported() -> Bool { + viewModels.count > 1 + } } // MARK: - TableView Configuration diff --git a/WooCommerce/Classes/ViewRelated/Orders/OrderListViewController.swift b/WooCommerce/Classes/ViewRelated/Orders/OrderListViewController.swift index 474b4e80646..1a2d1c8f955 100644 --- a/WooCommerce/Classes/ViewRelated/Orders/OrderListViewController.swift +++ b/WooCommerce/Classes/ViewRelated/Orders/OrderListViewController.swift @@ -626,8 +626,14 @@ extension OrderListViewController { /// Adds ability to select any order /// Used when opening an order with deep link /// - Parameter orderID: ID of the order to select in the list. + /// - Parameter isTriggeredByUserAction: Reflects if the order selection was triggered by a manual user action and not a view lifecycle update + /// Practically if the `isTriggeredByUserAction` is true, then the order details will be force presented + /// even if `selectedOrderID` is the same as the new `orderID` /// - Returns: Whether the order to select is in the list already (i.e. the order has been fetched and exists locally). - func selectOrderFromListIfPossible(for orderID: Int64) -> Bool { + func selectOrderFromListIfPossible( + for orderID: Int64, + isTriggeredByUserAction: Bool = false, + ) -> Bool { guard let dataSource else { return false } @@ -637,7 +643,7 @@ extension OrderListViewController { let orderNotAlreadySelected = selectedOrderID != orderID let indexPath = dataSource.indexPath(for: identifier) let indexPathNotAlreadySelected = selectedIndexPath != indexPath - let shouldSwitchDetails = orderNotAlreadySelected || indexPathNotAlreadySelected + let shouldSwitchDetails = orderNotAlreadySelected || indexPathNotAlreadySelected || isTriggeredByUserAction if shouldSwitchDetails { showOrderDetails(detailsViewModel.order) } diff --git a/WooCommerce/Classes/ViewRelated/Orders/OrdersRootViewController.swift b/WooCommerce/Classes/ViewRelated/Orders/OrdersRootViewController.swift index 066971cdc8c..9bc073c922d 100644 --- a/WooCommerce/Classes/ViewRelated/Orders/OrdersRootViewController.swift +++ b/WooCommerce/Classes/ViewRelated/Orders/OrdersRootViewController.swift @@ -165,7 +165,10 @@ final class OrdersRootViewController: UIViewController { /// - Returns: Whether the order to select is in the list already (i.e. the order has been fetched and exists locally). @discardableResult func selectOrderFromListIfPossible(for orderID: Int64) -> Bool { - ordersViewController.selectOrderFromListIfPossible(for: orderID) + ordersViewController.selectOrderFromListIfPossible( + for: orderID, + isTriggeredByUserAction: true + ) } /// Called when an order is shown externally (outside of `OrderListViewController`) and the order should be diff --git a/WooCommerce/Classes/ViewRelated/Orders/OrdersSplitViewWrapperController.swift b/WooCommerce/Classes/ViewRelated/Orders/OrdersSplitViewWrapperController.swift index f65ca2a9895..2db1da53fdc 100644 --- a/WooCommerce/Classes/ViewRelated/Orders/OrdersSplitViewWrapperController.swift +++ b/WooCommerce/Classes/ViewRelated/Orders/OrdersSplitViewWrapperController.swift @@ -129,10 +129,12 @@ private extension OrdersSplitViewWrapperController { // shown should replace the topViewController, to avoid having to tap back through several Order Details // screens in the navigation stack. The back button should always go to the Order List. // The up and down arrows are enabled when there is more than one item in `viewModels`. - guard isQuickOrderNavigationSupported(viewModels: viewModels), - let viewModel = viewModels[safe: currentIndex], - let secondaryNavigationController = ordersSplitViewController.viewController(for: .secondary) as? UINavigationController, - secondaryNavigationController.topViewController is OrderDetailsViewController else { + guard + let viewModel = viewModels[safe: currentIndex], + let secondaryNavigationController = ordersSplitViewController.viewController(for: .secondary) as? UINavigationController, + let existingOrderDetailsViewController = secondaryNavigationController.topViewController as? OrderDetailsViewController, + existingOrderDetailsViewController.isQuickOrderNavigationSupported() == orderDetailsViewController.isQuickOrderNavigationSupported() + else { // When showing an order without quick navigation, it simply sets the order details to the secondary view. let orderDetailsNavigationController = WooNavigationController(rootViewController: orderDetailsViewController) showSecondaryView(orderDetailsNavigationController) @@ -140,15 +142,17 @@ private extension OrdersSplitViewWrapperController { return } - secondaryNavigationController.replaceTopViewController(with: orderDetailsViewController, animated: false) - ordersViewController.onOrderSelected(id: viewModel.order.orderID) + if !existingOrderDetailsViewController.isPresentingViewModelOrder(viewModel) { + secondaryNavigationController.replaceTopViewController( + with: orderDetailsViewController, + animated: false + ) + ordersViewController.onOrderSelected(id: viewModel.order.orderID) + } + ordersSplitViewController.show(.secondary) onCompletion?(true) } - - func isQuickOrderNavigationSupported(viewModels: [OrderDetailsViewModel]) -> Bool { - viewModels.count > 1 - } } private extension OrdersSplitViewWrapperController {