Add cancellable property to secureBackup/recovery coordinators

This commit is contained in:
Arnaud Ringenbach
2022-03-09 10:41:48 +01:00
parent 1c11fc7243
commit 4c5ae7e4da
21 changed files with 93 additions and 43 deletions
@@ -31,6 +31,7 @@ final class SecureBackupSetupCoordinator: SecureBackupSetupCoordinatorType {
private let keyBackup: MXKeyBackup?
private let checkKeyBackup: Bool
private let allowOverwrite: Bool
private let cancellable: Bool
// MARK: Public
@@ -46,12 +47,14 @@ final class SecureBackupSetupCoordinator: SecureBackupSetupCoordinatorType {
/// - session: The MXSession.
/// - checkKeyBackup: Indicate false to ignore existing key backup.
/// - navigationRouter: Use existing navigation router to plug this flow or let nil to use new one.
init(session: MXSession, checkKeyBackup: Bool = true, allowOverwrite: Bool = false, navigationRouter: NavigationRouterType? = nil) {
/// - cancellable: Whether secure backup can be cancelled
init(session: MXSession, checkKeyBackup: Bool = true, allowOverwrite: Bool = false, navigationRouter: NavigationRouterType? = nil, cancellable: Bool) {
self.session = session
self.recoveryService = session.crypto.recoveryService
self.keyBackup = session.crypto.backup
self.checkKeyBackup = checkKeyBackup
self.allowOverwrite = allowOverwrite
self.cancellable = cancellable
if let navigationRouter = navigationRouter {
self.navigationRouter = navigationRouter
@@ -73,7 +76,9 @@ final class SecureBackupSetupCoordinator: SecureBackupSetupCoordinatorType {
}
func toPresentable() -> UIViewController {
return self.navigationRouter.toPresentable()
return self.navigationRouter
.toPresentable()
.vc_setModalFullScreen(!self.cancellable)
}
// MARK: - Private methods
@@ -81,13 +86,13 @@ final class SecureBackupSetupCoordinator: SecureBackupSetupCoordinatorType {
private func createIntro() -> SecureBackupSetupIntroViewController {
// TODO: Use a coordinator
let viewModel = SecureBackupSetupIntroViewModel(keyBackup: self.keyBackup, checkKeyBackup: self.checkKeyBackup)
let introViewController = SecureBackupSetupIntroViewController.instantiate(with: viewModel)
let introViewController = SecureBackupSetupIntroViewController.instantiate(with: viewModel, cancellable: self.cancellable)
introViewController.delegate = self
return introViewController
}
private func showSetupKey(passphraseOnly: Bool, passphrase: String? = nil) {
let coordinator = SecretsSetupRecoveryKeyCoordinator(recoveryService: self.recoveryService, passphrase: passphrase, passphraseOnly: passphraseOnly, allowOverwrite: allowOverwrite)
let coordinator = SecretsSetupRecoveryKeyCoordinator(recoveryService: self.recoveryService, passphrase: passphrase, passphraseOnly: passphraseOnly, allowOverwrite: allowOverwrite, cancellable: self.cancellable)
coordinator.delegate = self
coordinator.start()
@@ -98,7 +103,7 @@ final class SecureBackupSetupCoordinator: SecureBackupSetupCoordinatorType {
}
private func showSetupPassphrase() {
let coordinator = SecretsSetupRecoveryPassphraseCoordinator(passphraseInput: .new)
let coordinator = SecretsSetupRecoveryPassphraseCoordinator(passphraseInput: .new, cancellable: self.cancellable)
coordinator.delegate = self
coordinator.start()
@@ -109,7 +114,7 @@ final class SecureBackupSetupCoordinator: SecureBackupSetupCoordinatorType {
}
private func showSetupPassphraseConfirmation(with passphrase: String) {
let coordinator = SecretsSetupRecoveryPassphraseCoordinator(passphraseInput: .confirm(passphrase))
let coordinator = SecretsSetupRecoveryPassphraseCoordinator(passphraseInput: .confirm(passphrase), cancellable: self.cancellable)
coordinator.delegate = self
coordinator.start()