diff options
| author | Steffen Ernst <steffen.ernst@mullvad.net> | 2025-02-13 08:19:10 +0100 |
|---|---|---|
| committer | Steffen Ernst <steffen.ernst@mullvad.net> | 2025-02-17 09:40:34 +0100 |
| commit | 5dc09031dad361c916a0a392cff48a750671d069 (patch) | |
| tree | 9501a995a03c19c2a16c5ab1b75064ffeb938388 | |
| parent | f08ffd7bab6c71c89bc7078833479ce742c4cb10 (diff) | |
| download | mullvadvpn-5dc09031dad361c916a0a392cff48a750671d069.tar.xz mullvadvpn-5dc09031dad361c916a0a392cff48a750671d069.zip | |
Simplify flow continuation after purchase
6 files changed, 16 insertions, 36 deletions
diff --git a/ios/MullvadVPN/Coordinators/AccountCoordinator.swift b/ios/MullvadVPN/Coordinators/AccountCoordinator.swift index 8438c8997b..582115dfb4 100644 --- a/ios/MullvadVPN/Coordinators/AccountCoordinator.swift +++ b/ios/MullvadVPN/Coordinators/AccountCoordinator.swift @@ -84,7 +84,7 @@ final class AccountCoordinator: Coordinator, Presentable, Presenting, @unchecked accountNumber: accountNumber, paymentAction: paymentAction ) - coordinator.didFinish = { coordinator, _ in + coordinator.didFinish = { coordinator in coordinator.dismiss(animated: true) } coordinator.start() diff --git a/ios/MullvadVPN/Coordinators/InAppPurchaseCoordinator.swift b/ios/MullvadVPN/Coordinators/InAppPurchaseCoordinator.swift index 74ad68d72a..7105feab71 100644 --- a/ios/MullvadVPN/Coordinators/InAppPurchaseCoordinator.swift +++ b/ios/MullvadVPN/Coordinators/InAppPurchaseCoordinator.swift @@ -21,7 +21,7 @@ final class InAppPurchaseCoordinator: Coordinator, Presentable, Presenting { private let accountNumber: String private let paymentAction: PaymentAction - var didFinish: ((InAppPurchaseCoordinator, InAppPurchaseEvent) -> Void)? + var didFinish: ((InAppPurchaseCoordinator) -> Void)? var presentedViewController: UIViewController { return controller! @@ -33,8 +33,8 @@ final class InAppPurchaseCoordinator: Coordinator, Presentable, Presenting { self.paymentAction = paymentAction } - func dismiss(event: InAppPurchaseEvent) { - didFinish?(self, event) + func dismiss() { + didFinish?(self) } func start() { diff --git a/ios/MullvadVPN/Coordinators/OutOfTimeCoordinator.swift b/ios/MullvadVPN/Coordinators/OutOfTimeCoordinator.swift index ed86a10309..c052839591 100644 --- a/ios/MullvadVPN/Coordinators/OutOfTimeCoordinator.swift +++ b/ios/MullvadVPN/Coordinators/OutOfTimeCoordinator.swift @@ -82,14 +82,8 @@ class OutOfTimeCoordinator: Coordinator, Presenting, @preconcurrency OutOfTimeVi accountNumber: accountNumber, paymentAction: paymentAction ) - coordinator.didFinish = { [weak self] coordinator, event in + coordinator.didFinish = { coordinator in coordinator.dismiss(animated: true) - switch event { - case .paymentEvent(.finished), .purchaseRestored: - guard let self else { return } - self.didFinishPayment?(self) - default: break - } } coordinator.start() presentChild(coordinator, animated: true) diff --git a/ios/MullvadVPN/Coordinators/WelcomeCoordinator.swift b/ios/MullvadVPN/Coordinators/WelcomeCoordinator.swift index 15c1b36642..574418bb60 100644 --- a/ios/MullvadVPN/Coordinators/WelcomeCoordinator.swift +++ b/ios/MullvadVPN/Coordinators/WelcomeCoordinator.swift @@ -158,13 +158,8 @@ extension WelcomeCoordinator: @preconcurrency WelcomeViewControllerDelegate { accountNumber: accountNumber, paymentAction: .purchase ) - coordinator.didFinish = { [weak self] coordinator, event in + coordinator.didFinish = { coordinator in coordinator.dismiss(animated: true) - switch event { - case .paymentEvent(.finished): - self?.showSetupAccountCompleted() - default: break - } } coordinator.start() presentChild(coordinator, animated: true) diff --git a/ios/MullvadVPN/View controllers/Account/AccountInteractor.swift b/ios/MullvadVPN/View controllers/Account/AccountInteractor.swift index a9e6aec2d1..1a6583238e 100644 --- a/ios/MullvadVPN/View controllers/Account/AccountInteractor.swift +++ b/ios/MullvadVPN/View controllers/Account/AccountInteractor.swift @@ -21,7 +21,6 @@ final class AccountInteractor: Sendable { nonisolated(unsafe) var didReceiveDeviceState: (@Sendable (DeviceState) -> Void)? nonisolated(unsafe) private var tunnelObserver: TunnelObserver? - nonisolated(unsafe) private var paymentObserver: StorePaymentObserver? init( tunnelManager: TunnelManager, diff --git a/ios/MullvadVPN/View controllers/InAppPurchase/InAppPurchaseViewController.swift b/ios/MullvadVPN/View controllers/InAppPurchase/InAppPurchaseViewController.swift index 45f808b041..8c5b9e2bc0 100644 --- a/ios/MullvadVPN/View controllers/InAppPurchase/InAppPurchaseViewController.swift +++ b/ios/MullvadVPN/View controllers/InAppPurchase/InAppPurchaseViewController.swift @@ -9,14 +9,6 @@ import StoreKit import UIKit -enum InAppPurchaseEvent { - case paymentEvent(StorePaymentEvent) - case storePaymentError(StorePaymentManagerError) - case error(Error) - case cancelled - case purchaseRestored -} - class InAppPurchaseViewController: UIViewController, @preconcurrency StorePaymentObserver { private let storePaymentManager: StorePaymentManager private let accountNumber: String @@ -27,7 +19,7 @@ class InAppPurchaseViewController: UIViewController, @preconcurrency StorePaymen SpinnerActivityIndicatorView(style: .large) }() - var didFinish: ((InAppPurchaseEvent) -> Void)? + var didFinish: (() -> Void)? init( storePaymentManager: StorePaymentManager, @@ -74,10 +66,10 @@ class InAppPurchaseViewController: UIViewController, @preconcurrency StorePaymen self.showPurchaseOptions(for: products) case let .failure(failure as StorePaymentManagerError): self.errorPresenter.showAlertForError(failure, context: .purchase) { - self.didFinish?(.storePaymentError(failure)) + self.didFinish?() } case let .failure(failure): - self.didFinish?(.error(failure)) + self.didFinish?() } } } @@ -89,14 +81,14 @@ class InAppPurchaseViewController: UIViewController, @preconcurrency StorePaymen switch result { case let .success(success): self.errorPresenter.showAlertForResponse(success, context: .restoration) { - self.didFinish?(.purchaseRestored) + self.didFinish?() } case let .failure(failure as StorePaymentManagerError): self.errorPresenter.showAlertForError(failure, context: .restoration) { - self.didFinish?(.storePaymentError(failure)) + self.didFinish?() } case let .failure(failure): - self.didFinish?(.error(failure)) + self.didFinish?() } } } @@ -141,7 +133,7 @@ class InAppPurchaseViewController: UIViewController, @preconcurrency StorePaymen value: "Cancel", comment: "" ), style: .cancel) { _ in - self.didFinish?(.cancelled) + self.didFinish?() } cancelAction.accessibilityIdentifier = "actoin-sheet-cancel-button" sheetController.addAction(cancelAction) @@ -154,16 +146,16 @@ class InAppPurchaseViewController: UIViewController, @preconcurrency StorePaymen switch event { case let .finished(completion): errorPresenter.showAlertForResponse(completion.serverResponse, context: .purchase) { - self.didFinish?(.paymentEvent(event)) + self.didFinish?() } case let .failure(paymentFailure): switch paymentFailure.error { case .storePayment(SKError.paymentCancelled): - self.didFinish?(.paymentEvent(event)) + self.didFinish?() default: errorPresenter.showAlertForError(paymentFailure.error, context: .purchase) { - self.didFinish?(.paymentEvent(event)) + self.didFinish?() } } } |
