Skip to content

Commit 373de78

Browse files
authored
Merge pull request #8425 from woocommerce/issue/8423-order-details-link-bug
[Universal Links] Link does not open the order if the link store is already selected in the app
2 parents 3c3e38c + 83bb383 commit 373de78

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

WooCommerce/Classes/ViewRelated/MainTabBarController.swift

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ extension MainTabBarController {
337337
}
338338
let siteID = Int64(note.meta.identifier(forKey: .site) ?? Int.min)
339339

340-
switchToStore(with: siteID, onCompletion: { _ in
340+
showStore(with: siteID, onCompletion: { _ in
341341
presentNotificationDetails(for: note)
342342
})
343343
}
@@ -367,8 +367,16 @@ extension MainTabBarController {
367367
"already_read": note.read ])
368368
}
369369

370-
private static func switchToStore(with siteID: Int64, onCompletion: @escaping (Bool) -> Void) {
371-
SwitchStoreUseCase(stores: ServiceLocator.stores).switchToStoreIfSiteIsStored(with: siteID) { siteChanged in
370+
private static func showStore(with siteID: Int64, onCompletion: @escaping (Bool) -> Void) {
371+
let stores = ServiceLocator.stores
372+
373+
// Already showing that store, do nothing
374+
guard siteID != stores.sessionManager.defaultStoreID else {
375+
onCompletion(true)
376+
return
377+
}
378+
379+
SwitchStoreUseCase(stores: stores).switchToStoreIfSiteIsStored(with: siteID) { siteChanged in
372380
guard siteChanged else {
373381
return onCompletion(false)
374382
}
@@ -393,9 +401,10 @@ extension MainTabBarController {
393401
}
394402

395403
static func navigateToOrderDetails(with orderID: Int64, siteID: Int64) {
396-
switchToStore(with: siteID, onCompletion: { siteChanged in
404+
showStore(with: siteID, onCompletion: { storeIsShown in
397405
switchToOrdersTab {
398-
guard siteChanged else {
406+
// It failed to show the order's store. We navigate to the orders tab and stop, as we cannot show the order details screen
407+
guard storeIsShown else {
399408
return
400409
}
401410
// We give some time to the orders tab transition to finish, otherwise it might prevent the second navigation from happening

0 commit comments

Comments
 (0)