Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions WooCommerce/Classes/ViewRelated/MainTabBarController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ extension MainTabBarController {
}
let siteID = Int64(note.meta.identifier(forKey: .site) ?? Int.min)

switchToStore(with: siteID, onCompletion: { _ in
showStore(with: siteID, onCompletion: { _ in
presentNotificationDetails(for: note)
})
}
Expand Down Expand Up @@ -367,8 +367,16 @@ extension MainTabBarController {
"already_read": note.read ])
}

private static func switchToStore(with siteID: Int64, onCompletion: @escaping (Bool) -> Void) {
SwitchStoreUseCase(stores: ServiceLocator.stores).switchToStoreIfSiteIsStored(with: siteID) { siteChanged in
private static func showStore(with siteID: Int64, onCompletion: @escaping (Bool) -> Void) {
let stores = ServiceLocator.stores

// Already showing that store, do nothing
guard siteID != stores.sessionManager.defaultStoreID else {
onCompletion(true)
return
}

SwitchStoreUseCase(stores: stores).switchToStoreIfSiteIsStored(with: siteID) { siteChanged in
guard siteChanged else {
return onCompletion(false)
}
Expand All @@ -393,9 +401,10 @@ extension MainTabBarController {
}

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