-
Notifications
You must be signed in to change notification settings - Fork 336
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
868 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
ios/MullvadVPN/Coordinators/App/AccountDeletionCoordinator.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// | ||
// AccountDeletionCoordinator.swift | ||
// MullvadVPN | ||
// | ||
// Created by Mojgan on 2023-07-13. | ||
// Copyright © 2023 Mullvad VPN AB. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import UIKit | ||
|
||
final class AccountDeletionCoordinator: Coordinator, Presentable { | ||
private let navigationController: UINavigationController | ||
private let interactor: AccountDeletionInteractor | ||
|
||
var didCancel: ((AccountDeletionCoordinator) -> Void)? | ||
var didFinish: ((AccountDeletionCoordinator) -> Void)? | ||
|
||
var presentedViewController: UIViewController { | ||
navigationController | ||
} | ||
|
||
init( | ||
navigationController: UINavigationController, | ||
interactor: AccountDeletionInteractor | ||
) { | ||
self.navigationController = navigationController | ||
self.interactor = interactor | ||
} | ||
|
||
func start() { | ||
navigationController.navigationBar.isHidden = true | ||
let viewController = AccountDeletionViewController(interactor: interactor) | ||
viewController.delegate = self | ||
navigationController.pushViewController(viewController, animated: true) | ||
} | ||
} | ||
|
||
extension AccountDeletionCoordinator: AccountDeletionViewControllerDelegate { | ||
func deleteAccountDidSucceeded(controller: AccountDeletionViewController) { | ||
didFinish?(self) | ||
} | ||
|
||
func deleteAccountDidCancel(controller: AccountDeletionViewController) { | ||
didCancel?(self) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// | ||
// DeleteAccountOperation.swift | ||
// MullvadVPN | ||
// | ||
// Created by Mojgan on 2023-07-18. | ||
// Copyright © 2023 Mullvad VPN AB. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import MullvadLogging | ||
import MullvadREST | ||
import MullvadTypes | ||
import Operations | ||
|
||
class DeleteAccountOperation: ResultOperation<Bool> { | ||
private let logger = Logger(label: "\(DeleteAccountOperation.self)") | ||
|
||
private let accountNumber: String | ||
private let accountsProxy: REST.AccountsProxy | ||
private var task: Cancellable? | ||
|
||
init( | ||
dispatchQueue: DispatchQueue, | ||
accountsProxy: REST.AccountsProxy, | ||
accountNumber: String | ||
) { | ||
self.accountNumber = accountNumber | ||
self.accountsProxy = accountsProxy | ||
super.init(dispatchQueue: dispatchQueue) | ||
} | ||
|
||
override func main() { | ||
task = accountsProxy.deleteAccount( | ||
accountNumber: accountNumber, | ||
retryStrategy: .default, | ||
completion: { [weak self] result in | ||
self?.dispatchQueue.async { | ||
switch result { | ||
case let .success(isDeleted): | ||
self?.finish(result: .success(isDeleted)) | ||
case let .failure(error): | ||
self?.logger.error( | ||
error: error, | ||
message: "Failed to delete account." | ||
) | ||
self?.finish(result: .failure(error)) | ||
} | ||
} | ||
} | ||
) | ||
} | ||
|
||
override func operationDidCancel() { | ||
task?.cancel() | ||
task = nil | ||
} | ||
} |
Oops, something went wrong.