mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-05 11:58:32 +00:00
In preparation of FTUE changes... (#2556)
* Remove the welcome screen * Allow the UserSessionFlowCoordinator to control the whole app hierarchy, not only its splitView * Start using the new verification state listener * Rename Onboarding to AuthenticationStart in preparation for the new OnboardingFlowCoordinator; update snapshots and tests * Make the AuthenticationCoordinator a proper FlowCoordinator * Add some padding around the authentication start screen report a problem button * Bump the RustSDK to v1.1.49 * Only add bottom padding on the authentication start screen report a problem button
This commit is contained in:
@@ -41,6 +41,9 @@ class ClientProxy: ClientProxyProtocol {
|
||||
// periphery:ignore - required for instance retention in the rust codebase
|
||||
private var ignoredUsersListenerTaskHandle: TaskHandle?
|
||||
|
||||
// periphery:ignore - required for instance retention in the rust codebase
|
||||
private var verificationStateListenerTaskHandle: TaskHandle?
|
||||
|
||||
private var delegateHandle: TaskHandle?
|
||||
|
||||
// These following summary providers both operate on the same allRooms() list but
|
||||
@@ -111,6 +114,11 @@ class ClientProxy: ClientProxyProtocol {
|
||||
loadingStateSubject.asCurrentValuePublisher()
|
||||
}
|
||||
|
||||
private let verificationStateSubject = CurrentValueSubject<SessionVerificationState, Never>(.unknown)
|
||||
var verificationStatePublisher: CurrentValuePublisher<SessionVerificationState, Never> {
|
||||
verificationStateSubject.asCurrentValuePublisher()
|
||||
}
|
||||
|
||||
init(client: ClientProtocol,
|
||||
backgroundTaskService: BackgroundTaskServiceProtocol,
|
||||
appSettings: AppSettings,
|
||||
@@ -151,6 +159,25 @@ class ClientProxy: ClientProxyProtocol {
|
||||
ignoredUsersListenerTaskHandle = client.subscribeToIgnoredUsers(listener: IgnoredUsersListenerProxy { [weak self] ignoredUsers in
|
||||
self?.ignoredUsersSubject.send(ignoredUsers)
|
||||
})
|
||||
|
||||
updateVerificationState(client.encryption().verificationState())
|
||||
|
||||
verificationStateListenerTaskHandle = client.encryption().verificationStateListener(listener: VerificationStateListenerProxy { [weak self] verificationState in
|
||||
self?.updateVerificationState(verificationState)
|
||||
})
|
||||
}
|
||||
|
||||
private func updateVerificationState(_ verificationState: VerificationState) {
|
||||
let verificationState: SessionVerificationState = switch verificationState {
|
||||
case .unknown:
|
||||
.unknown
|
||||
case .unverified:
|
||||
.unverified
|
||||
case .verified:
|
||||
.verified
|
||||
}
|
||||
|
||||
verificationStateSubject.send(verificationState)
|
||||
}
|
||||
|
||||
var userID: String {
|
||||
@@ -745,6 +772,18 @@ private class RoomListServiceSyncIndicatorListenerProxy: RoomListServiceSyncIndi
|
||||
}
|
||||
}
|
||||
|
||||
private class VerificationStateListenerProxy: VerificationStateListener {
|
||||
private let onUpdateClosure: (VerificationState) -> Void
|
||||
|
||||
init(onUpdateClosure: @escaping (VerificationState) -> Void) {
|
||||
self.onUpdateClosure = onUpdateClosure
|
||||
}
|
||||
|
||||
func onUpdate(status: VerificationState) {
|
||||
onUpdateClosure(status)
|
||||
}
|
||||
}
|
||||
|
||||
private class ClientDelegateWrapper: ClientDelegate {
|
||||
private let authErrorCallback: (Bool) -> Void
|
||||
|
||||
|
||||
@@ -71,12 +71,20 @@ struct PusherConfiguration {
|
||||
let lang: String
|
||||
}
|
||||
|
||||
enum SessionVerificationState {
|
||||
case unknown
|
||||
case verified
|
||||
case unverified
|
||||
}
|
||||
|
||||
// sourcery: AutoMockable
|
||||
protocol ClientProxyProtocol: AnyObject, MediaLoaderProtocol {
|
||||
var actionsPublisher: AnyPublisher<ClientProxyAction, Never> { get }
|
||||
|
||||
var loadingStatePublisher: CurrentValuePublisher<ClientProxyLoadingState, Never> { get }
|
||||
|
||||
var verificationStatePublisher: CurrentValuePublisher<SessionVerificationState, Never> { get }
|
||||
|
||||
var userID: String { get }
|
||||
|
||||
var deviceID: String? { get }
|
||||
|
||||
@@ -22,8 +22,6 @@ class UserSession: UserSessionProtocol {
|
||||
|
||||
private var cancellables = Set<AnyCancellable>()
|
||||
|
||||
private var retrieveSessionVerificationControllerTask: Task<Void, Never>?
|
||||
|
||||
private var authErrorCancellable: AnyCancellable?
|
||||
|
||||
var userID: String { clientProxy.userID }
|
||||
@@ -36,20 +34,6 @@ class UserSession: UserSessionProtocol {
|
||||
|
||||
let callbacks = PassthroughSubject<UserSessionCallback, Never>()
|
||||
|
||||
private(set) var sessionVerificationController: SessionVerificationControllerProxyProtocol? {
|
||||
didSet {
|
||||
sessionVerificationController?.callbacks.sink { [weak self] callback in
|
||||
switch callback {
|
||||
case .finished:
|
||||
self?.sessionVerificationStateSubject.send(.verified)
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
}
|
||||
}
|
||||
|
||||
let sessionSecurityStateSubject = CurrentValueSubject<SessionSecurityState, Never>(.init(verificationState: .unknown, recoveryState: .unknown))
|
||||
var sessionSecurityStatePublisher: CurrentValuePublisher<SessionSecurityState, Never> {
|
||||
sessionSecurityStateSubject.asCurrentValuePublisher()
|
||||
@@ -60,15 +44,6 @@ class UserSession: UserSessionProtocol {
|
||||
self.mediaProvider = mediaProvider
|
||||
self.voiceMessageMediaManager = voiceMessageMediaManager
|
||||
|
||||
clientProxy.actionsPublisher
|
||||
.receive(on: DispatchQueue.main)
|
||||
.sink { [weak self] callback in
|
||||
if callback.isSyncUpdate {
|
||||
self?.checkSessionVerificationState()
|
||||
}
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
authErrorCancellable = clientProxy.actionsPublisher
|
||||
.receive(on: DispatchQueue.main)
|
||||
.sink { [weak self] callback in
|
||||
@@ -82,7 +57,7 @@ class UserSession: UserSessionProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
Publishers.CombineLatest(sessionVerificationStateSubject, clientProxy.secureBackupController.recoveryState)
|
||||
Publishers.CombineLatest(clientProxy.verificationStatePublisher, clientProxy.secureBackupController.recoveryState)
|
||||
.map {
|
||||
MXLog.info("Session security state changed, verificationState: \($0), recoveryState: \($1)")
|
||||
return SessionSecurityState(verificationState: $0, recoveryState: $1)
|
||||
@@ -94,62 +69,4 @@ class UserSession: UserSessionProtocol {
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private func checkSessionVerificationState() {
|
||||
guard retrieveSessionVerificationControllerTask == nil else {
|
||||
MXLog.info("Session verification state check already in progress")
|
||||
return
|
||||
}
|
||||
|
||||
guard sessionVerificationController == nil else {
|
||||
Task {
|
||||
await updateSessionVerificationState()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
MXLog.info("Retrieving session verification controller")
|
||||
|
||||
retrieveSessionVerificationControllerTask = Task {
|
||||
switch await clientProxy.sessionVerificationControllerProxy() {
|
||||
case .success(let sessionVerificationController):
|
||||
self.sessionVerificationController = sessionVerificationController
|
||||
await updateSessionVerificationState()
|
||||
|
||||
retrieveSessionVerificationControllerTask = nil
|
||||
case .failure(let error):
|
||||
MXLog.info("Failed getting session verification controller with error: \(error). Will retry on the next sync update.")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func updateSessionVerificationState() async {
|
||||
guard let sessionVerificationController else {
|
||||
fatalError("This point should never be reached")
|
||||
}
|
||||
|
||||
MXLog.info("Checking session verification state")
|
||||
|
||||
guard case let .success(isVerified) = await sessionVerificationController.isVerified() else {
|
||||
MXLog.error("Failed checking verification state. Will retry on the next sync update.")
|
||||
return
|
||||
}
|
||||
|
||||
if isVerified {
|
||||
sessionVerificationStateSubject.send(.verified)
|
||||
} else {
|
||||
guard case let .success(isLastDevice) = await clientProxy.isOnlyDeviceLeft() else {
|
||||
MXLog.error("Failed checking isLastDevice. Will retry on the next sync update.")
|
||||
return
|
||||
}
|
||||
|
||||
if isLastDevice {
|
||||
sessionVerificationStateSubject.send(.unverifiedLastSession)
|
||||
} else {
|
||||
sessionVerificationStateSubject.send(.unverified)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,13 +21,6 @@ enum UserSessionCallback {
|
||||
case didReceiveAuthError(isSoftLogout: Bool)
|
||||
}
|
||||
|
||||
enum SessionVerificationState {
|
||||
case unknown
|
||||
case verified
|
||||
case unverified
|
||||
case unverifiedLastSession
|
||||
}
|
||||
|
||||
struct SessionSecurityState: Equatable {
|
||||
let verificationState: SessionVerificationState
|
||||
let recoveryState: SecureBackupRecoveryState
|
||||
@@ -43,7 +36,6 @@ protocol UserSessionProtocol {
|
||||
var voiceMessageMediaManager: VoiceMessageMediaManagerProtocol { get }
|
||||
|
||||
var sessionSecurityStatePublisher: CurrentValuePublisher<SessionSecurityState, Never> { get }
|
||||
var sessionVerificationController: SessionVerificationControllerProxyProtocol? { get }
|
||||
|
||||
var callbacks: PassthroughSubject<UserSessionCallback, Never> { get }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user