mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Make LinkNewDeviceScreen fall back to the App Lock PIN code when there's no passcode. (#5794)
* Fall back to the AppLock PIN code when there's no passcode. * Add extra tests on the LinkNewDeviceFlowCoordinator. * Misc tweaks for clarification. * Regenerate snapshots.
This commit is contained in:
@@ -11,6 +11,7 @@ import SwiftUI
|
||||
enum LinkNewDeviceScreenCoordinatorAction {
|
||||
case linkMobileDevice(LinkNewDeviceService.LinkMobileProgressPublisher)
|
||||
case linkDesktopComputer
|
||||
case verifyWithAppLockPIN(CheckedContinuation<Bool, Never>)
|
||||
case dismiss
|
||||
}
|
||||
|
||||
@@ -47,6 +48,8 @@ final class LinkNewDeviceScreenCoordinator: CoordinatorProtocol {
|
||||
actionsSubject.send(.linkMobileDevice(progressPublisher))
|
||||
case .linkDesktopComputer:
|
||||
actionsSubject.send(.linkDesktopComputer)
|
||||
case .verifyWithAppLockPIN(let continuation):
|
||||
actionsSubject.send(.verifyWithAppLockPIN(continuation))
|
||||
case .dismiss:
|
||||
actionsSubject.send(.dismiss)
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import Foundation
|
||||
enum LinkNewDeviceScreenViewModelAction {
|
||||
case linkMobileDevice(LinkNewDeviceService.LinkMobileProgressPublisher)
|
||||
case linkDesktopComputer
|
||||
case verifyWithAppLockPIN(CheckedContinuation<Bool, Never>)
|
||||
case dismiss
|
||||
}
|
||||
|
||||
|
||||
@@ -72,8 +72,10 @@ class LinkNewDeviceScreenViewModel: LinkNewDeviceScreenViewModelType, LinkNewDev
|
||||
case .verified, .unavailable:
|
||||
break
|
||||
case .appLockPINRequired:
|
||||
// Follow-up PR: present the App Lock PIN screen to verify the device owner.
|
||||
return
|
||||
guard await verifyWithAppLockPIN() else {
|
||||
state.mode = .readyToLink(.idle)
|
||||
return
|
||||
}
|
||||
case .cancelled, .unverified:
|
||||
state.mode = .readyToLink(.idle)
|
||||
return
|
||||
@@ -92,6 +94,13 @@ class LinkNewDeviceScreenViewModel: LinkNewDeviceScreenViewModelType, LinkNewDev
|
||||
}
|
||||
}
|
||||
|
||||
/// Asks the coordinator to verify the device owner with the App Lock PIN, suspending until it has a result.
|
||||
private func verifyWithAppLockPIN() async -> Bool {
|
||||
await withCheckedContinuation { continuation in
|
||||
actionsSubject.send(.verifyWithAppLockPIN(continuation))
|
||||
}
|
||||
}
|
||||
|
||||
private func linkMobileDevice() async {
|
||||
state.mode = .readyToLink(.generatingCode)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user