@@ -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