diff --git a/PlatformParticles/PlatformParticles.xcodeproj/project.pbxproj b/PlatformParticles/PlatformParticles.xcodeproj/project.pbxproj index b44a74451..d986c54c2 100644 --- a/PlatformParticles/PlatformParticles.xcodeproj/project.pbxproj +++ b/PlatformParticles/PlatformParticles.xcodeproj/project.pbxproj @@ -8,7 +8,6 @@ /* Begin PBXBuildFile section */ 0271236928E545A50015D39F /* SwiftMessages in Frameworks */ = {isa = PBXBuildFile; productRef = 0271236828E545A50015D39F /* SwiftMessages */; }; - 27897DA02C93EA2800196F21 /* DismissPresentedAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27897D922C93EA2800196F21 /* DismissPresentedAction.swift */; }; 27ED353A2AD5BD0900C159F5 /* BannerErrorAlert.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27ED35392AD5BD0900C159F5 /* BannerErrorAlert.swift */; }; 3101F9C52511303E00AC4010 /* ConfirmAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3101F9C42511303E00AC4010 /* ConfirmAction.swift */; }; 3101F9C62511303E00AC4010 /* ConfirmAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3101F9C42511303E00AC4010 /* ConfirmAction.swift */; }; @@ -635,7 +634,6 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ - 27897D922C93EA2800196F21 /* DismissPresentedAction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DismissPresentedAction.swift; sourceTree = ""; }; 27ED35392AD5BD0900C159F5 /* BannerErrorAlert.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BannerErrorAlert.swift; sourceTree = ""; }; 3101F9C42511303E00AC4010 /* ConfirmAction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConfirmAction.swift; sourceTree = ""; }; 3101F9C92511308E00AC4010 /* AuthLoginPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthLoginPresenter.swift; sourceTree = ""; }; @@ -1170,7 +1168,6 @@ 314B5FA223DCCE2800139EB3 /* ConfirmationAction.swift */, 3101F9C42511303E00AC4010 /* ConfirmAction.swift */, 3180B04E272B509400CCAB67 /* DismissAction.swift */, - 27897D922C93EA2800196F21 /* DismissPresentedAction.swift */, 64AF47822817123C00EBFDC6 /* SafariAction.swift */, ); path = _Actions; @@ -2349,7 +2346,6 @@ 3128DDF026B89CE80099B62E /* LikedTableViewListPresenter.swift in Sources */, 314B604D23DCCE2900139EB3 /* ListPresenterManager.swift in Sources */, 314B5FD123DCCE2900139EB3 /* PrivacyPermissionPresenter.swift in Sources */, - 27897DA02C93EA2800196F21 /* DismissPresentedAction.swift in Sources */, 314B5FE323DCCE2900139EB3 /* ObjectPresenterCollectionViewCell.swift in Sources */, 314B5FE123DCCE2900139EB3 /* UIView+Xib.swift in Sources */, 3101F9C52511303E00AC4010 /* ConfirmAction.swift in Sources */, diff --git a/PlatformParticles/PlatformParticles/_Actions/DismissAction.swift b/PlatformParticles/PlatformParticles/_Actions/DismissAction.swift index 06bd52744..a02645751 100644 --- a/PlatformParticles/PlatformParticles/_Actions/DismissAction.swift +++ b/PlatformParticles/PlatformParticles/_Actions/DismissAction.swift @@ -21,7 +21,12 @@ private class DismissAction: NSObject, NavigableProtocol { @objc open func navigate(to request: RoutingRequest?, animated: Bool, completion: RoutingCompletionBlock?) { if request?.path == "/action/dismiss" { let viewController = UIViewController.topmost() - if viewController?.navigationController?.topViewController == viewController, + if let shouldPrioritizeDismiss = request?.params?["shouldPrioritizeDismiss"] as? Bool, + shouldPrioritizeDismiss && viewController?.presentingViewController !== nil { + viewController?.dismiss(animated: animated, completion: { + completion?(nil, true) + }) + } else if viewController?.navigationController?.topViewController == viewController, viewController?.navigationController?.viewControllers.count ?? 0 > 1 { viewController?.navigationController?.popViewController(animated: animated) } else if viewController?.presentingViewController !== nil { diff --git a/PlatformParticles/PlatformParticles/_Actions/DismissPresentedAction.swift b/PlatformParticles/PlatformParticles/_Actions/DismissPresentedAction.swift deleted file mode 100644 index ed107f9be..000000000 --- a/PlatformParticles/PlatformParticles/_Actions/DismissPresentedAction.swift +++ /dev/null @@ -1,33 +0,0 @@ -// -// DismissPresentedAction.swift -// PlatformParticles -// -// Created by Mike Maguire on 9/15/24. -// Copyright © 2024 dYdX. All rights reserved. -// - -import ParticlesKit -import RoutingKit -import Utilities - -public class DismissPresentedActionBuilder: NSObject, ObjectBuilderProtocol { - public func build() -> T? { - let action = DismissPresentedAction() - return action as? T - } -} - -private class DismissPresentedAction: NSObject, NavigableProtocol { - @objc open func navigate(to request: RoutingRequest?, animated: Bool, completion: RoutingCompletionBlock?) { - if request?.path == "/action/dismiss_presented" { - let viewController = UIViewController.topmost() - if viewController?.presentingViewController !== nil { - viewController?.dismiss(animated: true, completion: { - completion?(nil, true) - }) - } - } else { - completion?(nil, false) - } - } -} diff --git a/dydx/dydxPresenters/dydxPresenters/_Features/routing_swiftui.json b/dydx/dydxPresenters/dydxPresenters/_Features/routing_swiftui.json index 31afa8376..215199aff 100644 --- a/dydx/dydxPresenters/dydxPresenters/_Features/routing_swiftui.json +++ b/dydx/dydxPresenters/dydxPresenters/_Features/routing_swiftui.json @@ -60,9 +60,6 @@ "/action/dismiss": { "destination":"PlatformParticles.DismissActionBuilder" }, - "/action/dismiss_presented": { - "destination":"PlatformParticles.DismissPresentedActionBuilder" - }, "/action/order/cancel": { "destination":"dydxPresenters.dydxCancelOrderActionBuilder" }, diff --git a/dydx/dydxPresenters/dydxPresenters/_v4/Vault/DepositsAndWithdrawals/dydxVaultDepositWithdrawConfirmationViewBuilder.swift b/dydx/dydxPresenters/dydxPresenters/_v4/Vault/DepositsAndWithdrawals/dydxVaultDepositWithdrawConfirmationViewBuilder.swift index 6f717d906..7546a2a17 100644 --- a/dydx/dydxPresenters/dydxPresenters/_v4/Vault/DepositsAndWithdrawals/dydxVaultDepositWithdrawConfirmationViewBuilder.swift +++ b/dydx/dydxPresenters/dydxPresenters/_v4/Vault/DepositsAndWithdrawals/dydxVaultDepositWithdrawConfirmationViewBuilder.swift @@ -83,7 +83,7 @@ private class dydxVaultDepositWithdrawConfirmationViewPresenter: HostedViewPrese DispatchQueue.main.asyncAfter(deadline: .now() + 2) { if Int.random(in: 1...6) == 1 { // success - Router.shared?.navigate(to: RoutingRequest(path: "/action/dismiss_presented"), animated: true, completion: nil) + Router.shared?.navigate(to: RoutingRequest(path: "/action/dismiss", params: ["shouldPrioritizeDismiss": true]), animated: true, completion: nil) } else { // failure self?.viewModel?.isFirstSubmission = false @@ -138,7 +138,7 @@ private class dydxVaultDepositWithdrawConfirmationViewPresenter: HostedViewPrese let curFreeCollateral = subaccount?.freeCollateral?.current?.doubleValue, let curMarginUsage = subaccount?.marginUsage?.current?.doubleValue else { - assertionFailure() +// assertionFailure() return }