mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-10-31 16:24:11 +00:00
Fixes #3231 - Rewrite how out of band verification changes are handled within the onboarding flows
This commit is contained in:
committed by
Stefan Ceriu
parent
b43797f4bf
commit
2da4059718
@@ -61,6 +61,8 @@ class OnboardingFlowCoordinator: FlowCoordinatorProtocol {
|
|||||||
actionsSubject.eraseToAnyPublisher()
|
actionsSubject.eraseToAnyPublisher()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var verificationStateCancellable: AnyCancellable?
|
||||||
|
|
||||||
init(userSession: UserSessionProtocol,
|
init(userSession: UserSessionProtocol,
|
||||||
appLockService: AppLockServiceProtocol,
|
appLockService: AppLockServiceProtocol,
|
||||||
analyticsService: AnalyticsService,
|
analyticsService: AnalyticsService,
|
||||||
@@ -83,6 +85,21 @@ class OnboardingFlowCoordinator: FlowCoordinatorProtocol {
|
|||||||
self.navigationStackCoordinator = NavigationStackCoordinator()
|
self.navigationStackCoordinator = NavigationStackCoordinator()
|
||||||
|
|
||||||
stateMachine = .init(state: .initial)
|
stateMachine = .init(state: .initial)
|
||||||
|
|
||||||
|
// Always react to verification changes, not only when freshly
|
||||||
|
// verified from
|
||||||
|
verificationStateCancellable = userSession.sessionSecurityStatePublisher
|
||||||
|
.map(\.verificationState)
|
||||||
|
.removeDuplicates()
|
||||||
|
.sink { [weak self] value in
|
||||||
|
guard let self,
|
||||||
|
value == .verified,
|
||||||
|
stateMachine.state == .identityConfirmation else { return }
|
||||||
|
|
||||||
|
appSettings.hasRunIdentityConfirmationOnboarding = true
|
||||||
|
stateMachine.tryEvent(.nextSkippingIdentityConfimed)
|
||||||
|
self.verificationStateCancellable = nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var shouldStart: Bool {
|
var shouldStart: Bool {
|
||||||
@@ -249,27 +266,7 @@ class OnboardingFlowCoordinator: FlowCoordinatorProtocol {
|
|||||||
}
|
}
|
||||||
.store(in: &cancellables)
|
.store(in: &cancellables)
|
||||||
|
|
||||||
// If the verification state is still unknown wait for it to resolve
|
presentCoordinator(coordinator)
|
||||||
// and just move on to the next steps if verified
|
|
||||||
var verificationStateCancellable: AnyCancellable?
|
|
||||||
if userSession.sessionSecurityStatePublisher.value.verificationState == .unknown {
|
|
||||||
verificationStateCancellable = userSession.sessionSecurityStatePublisher
|
|
||||||
.map(\.verificationState)
|
|
||||||
.removeDuplicates()
|
|
||||||
.sink { [weak self] value in
|
|
||||||
guard let self else { return }
|
|
||||||
|
|
||||||
if value == .verified {
|
|
||||||
appSettings.hasRunIdentityConfirmationOnboarding = true
|
|
||||||
stateMachine.tryEvent(.nextSkippingIdentityConfimed)
|
|
||||||
verificationStateCancellable?.cancel()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
presentCoordinator(coordinator) { [verificationStateCancellable] in
|
|
||||||
verificationStateCancellable?.cancel()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private func presentSessionVerificationScreen() async {
|
private func presentSessionVerificationScreen() async {
|
||||||
@@ -287,8 +284,7 @@ class OnboardingFlowCoordinator: FlowCoordinatorProtocol {
|
|||||||
|
|
||||||
switch action {
|
switch action {
|
||||||
case .done:
|
case .done:
|
||||||
appSettings.hasRunIdentityConfirmationOnboarding = true
|
break // Moving to next state is handled by the global session verification listener
|
||||||
stateMachine.tryEvent(.next)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.store(in: &cancellables)
|
.store(in: &cancellables)
|
||||||
@@ -309,8 +305,7 @@ class OnboardingFlowCoordinator: FlowCoordinatorProtocol {
|
|||||||
|
|
||||||
switch action {
|
switch action {
|
||||||
case .recoveryFixed:
|
case .recoveryFixed:
|
||||||
appSettings.hasRunIdentityConfirmationOnboarding = true
|
break // Moving to next state is Handled by the global session verification listener
|
||||||
stateMachine.tryEvent(.next)
|
|
||||||
case .resetEncryption:
|
case .resetEncryption:
|
||||||
presentEncryptionResetScreen()
|
presentEncryptionResetScreen()
|
||||||
default:
|
default:
|
||||||
@@ -338,8 +333,7 @@ class OnboardingFlowCoordinator: FlowCoordinatorProtocol {
|
|||||||
case .requestOIDCAuthorisation(let url):
|
case .requestOIDCAuthorisation(let url):
|
||||||
presentOIDCAuthorisationScreen(url: url)
|
presentOIDCAuthorisationScreen(url: url)
|
||||||
case .resetFinished:
|
case .resetFinished:
|
||||||
appSettings.hasRunIdentityConfirmationOnboarding = true
|
// Moving to next state is handled by the global session verification listener
|
||||||
stateMachine.tryEvent(.next)
|
|
||||||
navigationStackCoordinator.setSheetCoordinator(nil)
|
navigationStackCoordinator.setSheetCoordinator(nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user