Skip to content

Commit f345384

Browse files
committed
Fix crash when saving shipping label after opening order from push notification
1 parent 16adfbd commit f345384

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

WooCommerce/Classes/ViewRelated/Orders/Order Details/OrderDetailsViewController.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,8 +547,15 @@ private extension OrderDetailsViewController {
547547
}
548548
}
549549
shippingLabelFormVC.onLabelSave = { [weak self] in
550-
guard let self = self else { return }
551-
self.navigationController?.popToViewController(self, animated: true)
550+
guard let self = self, let navigationController = self.navigationController, navigationController.viewControllers.contains(self) else {
551+
// Navigate back to order details when presented from push notification
552+
if let orderLoaderVC = self?.parent as? OrderLoaderViewController {
553+
self?.navigationController?.popToViewController(orderLoaderVC, animated: true)
554+
}
555+
return
556+
}
557+
558+
navigationController.popToViewController(self, animated: true)
552559
}
553560
shippingLabelFormVC.hidesBottomBarWhenPushed = true
554561
navigationController?.show(shippingLabelFormVC, sender: self)

0 commit comments

Comments
 (0)