mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
More secure backup tweaks (#2212)
* Make sure the indicator for disabling backups is dismissed together with the screen * Get rid of the .disabled key backup state as it has no correspondant on the rust side and is confusing * Remove superflous BackupState extensions, add more logs
This commit is contained in:
+17
-4
@@ -21,6 +21,7 @@ typealias SecureBackupKeyBackupScreenViewModelType = StateStoreViewModel<SecureB
|
||||
|
||||
class SecureBackupKeyBackupScreenViewModel: SecureBackupKeyBackupScreenViewModelType, SecureBackupKeyBackupScreenViewModelProtocol {
|
||||
private let secureBackupController: SecureBackupControllerProtocol
|
||||
private let userIndicatorController: UserIndicatorControllerProtocol?
|
||||
|
||||
private var actionsSubject: PassthroughSubject<SecureBackupKeyBackupScreenViewModelAction, Never> = .init()
|
||||
var actions: AnyPublisher<SecureBackupKeyBackupScreenViewModelAction, Never> {
|
||||
@@ -29,18 +30,18 @@ class SecureBackupKeyBackupScreenViewModel: SecureBackupKeyBackupScreenViewModel
|
||||
|
||||
init(secureBackupController: SecureBackupControllerProtocol, userIndicatorController: UserIndicatorControllerProtocol?) {
|
||||
self.secureBackupController = secureBackupController
|
||||
self.userIndicatorController = userIndicatorController
|
||||
|
||||
super.init(initialViewState: .init(mode: secureBackupController.keyBackupState.value.viewMode))
|
||||
|
||||
secureBackupController.keyBackupState
|
||||
.receive(on: DispatchQueue.main)
|
||||
.sink { [weak userIndicatorController] state in
|
||||
let loadingIndicatorIdentifier = "SecureBackupKeyBackupScreenLoading"
|
||||
.sink { [weak self] state in
|
||||
switch state {
|
||||
case .disabling, .enabling, .unknown:
|
||||
userIndicatorController?.submitIndicator(.init(id: loadingIndicatorIdentifier, type: .modal, title: L10n.commonLoading, persistent: true))
|
||||
self?.showLoadingIndicator()
|
||||
default:
|
||||
userIndicatorController?.retractIndicatorWithId(loadingIndicatorIdentifier)
|
||||
self?.dismissLoadingIndicator()
|
||||
}
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
@@ -80,8 +81,20 @@ class SecureBackupKeyBackupScreenViewModel: SecureBackupKeyBackupScreenViewModel
|
||||
MXLog.error("Failed disabling key backup with error: \(error)")
|
||||
state.bindings.alertInfo = .init(id: .init())
|
||||
}
|
||||
|
||||
dismissLoadingIndicator()
|
||||
}
|
||||
}
|
||||
|
||||
private static let loadingIndicatorIdentifier = "SecureBackupKeyBackupScreenLoading"
|
||||
|
||||
private func showLoadingIndicator() {
|
||||
userIndicatorController?.submitIndicator(.init(id: Self.loadingIndicatorIdentifier, type: .modal, title: L10n.commonLoading, persistent: true))
|
||||
}
|
||||
|
||||
private func dismissLoadingIndicator() {
|
||||
userIndicatorController?.retractIndicatorWithId(Self.loadingIndicatorIdentifier)
|
||||
}
|
||||
}
|
||||
|
||||
extension SecureBackupKeyBackupState {
|
||||
|
||||
Reference in New Issue
Block a user