Adopt StateStoreViewModelV2 in the remaining settings screens. (#4158)

* Move the AuthenticationStartScreen into the Authentication directory.

* Commit the updated Sentry license.

No idea why they dropped the 2024 🤷‍♂️

* Use StateStoreViewModelV2 in BugReportScreen.

* Use StateStoreViewModelV2 in UserDetailsEditScreen.

* Use StateStoreViewModelV2 in NotificationSettingsScreen.

* Use StateStoreViewModelV2 in NotificationSettingsEditScreen.

* Use StateStoreViewModelV2 in LegalInformationScreen.

* Use StateStoreViewModelV2 in LogViewerScreen.

* Use StateStoreViewModelV2 in AnalyticsSettingsScreen.

* Rename AdvancedSettingsScreen directory.

* Use StateStoreViewModelV2 in EncryptionResetScreen.

* Use StateStoreViewModelV2 in EncryptionResetPasswordScreen.

* Use StateStoreViewModelV2 in SecureBackup…Screens.

* Use StateStoreViewModelV2 in LoginScreen.

Seems this one was ignored waiting on the fulfillment transitionValues implementation.

* Use StateStoreViewModelV2 in DeactivateAccountScreen.

* Move DeactivateAccountScreen into the Settings directory.
This commit is contained in:
Doug
2025-05-30 12:24:56 +01:00
committed by GitHub
parent 565ca3ab0b
commit 458c6aaa57
54 changed files with 238 additions and 294 deletions
@@ -8,7 +8,7 @@
import Combine
import SwiftUI
typealias SecureBackupKeyBackupScreenViewModelType = StateStoreViewModel<SecureBackupKeyBackupScreenViewState, SecureBackupKeyBackupScreenViewAction>
typealias SecureBackupKeyBackupScreenViewModelType = StateStoreViewModelV2<SecureBackupKeyBackupScreenViewState, SecureBackupKeyBackupScreenViewAction>
class SecureBackupKeyBackupScreenViewModel: SecureBackupKeyBackupScreenViewModelType, SecureBackupKeyBackupScreenViewModelProtocol {
private let secureBackupController: SecureBackupControllerProtocol
@@ -10,7 +10,7 @@ import Compound
import SwiftUI
struct SecureBackupKeyBackupScreen: View {
@ObservedObject var context: SecureBackupKeyBackupScreenViewModel.Context
@Bindable var context: SecureBackupKeyBackupScreenViewModel.Context
var body: some View {
FullscreenDialog {
@@ -8,7 +8,7 @@
import Combine
import SwiftUI
typealias SecureBackupLogoutConfirmationScreenViewModelType = StateStoreViewModel<SecureBackupLogoutConfirmationScreenViewState, SecureBackupLogoutConfirmationScreenViewAction>
typealias SecureBackupLogoutConfirmationScreenViewModelType = StateStoreViewModelV2<SecureBackupLogoutConfirmationScreenViewState, SecureBackupLogoutConfirmationScreenViewAction>
class SecureBackupLogoutConfirmationScreenViewModel: SecureBackupLogoutConfirmationScreenViewModelType, SecureBackupLogoutConfirmationScreenViewModelProtocol {
private let secureBackupController: SecureBackupControllerProtocol
@@ -10,7 +10,7 @@ import Compound
import SwiftUI
struct SecureBackupLogoutConfirmationScreen: View {
@ObservedObject var context: SecureBackupLogoutConfirmationScreenViewModel.Context
@Bindable var context: SecureBackupLogoutConfirmationScreenViewModel.Context
var body: some View {
FullscreenDialog {
@@ -126,26 +126,26 @@ struct SecureBackupLogoutConfirmationScreen_Previews: PreviewProvider, TestableP
SecureBackupLogoutConfirmationScreen(context: waitingViewModel.context)
}
.previewDisplayName("Waiting")
.snapshotPreferences(expect: waitingViewModel.context.$viewState.map { $0.mode == .waitingToStart(hasStalled: false) })
.snapshotPreferences(expect: waitingViewModel.context.observe(\.viewState.mode).map { $0 == .waitingToStart(hasStalled: false) }.eraseToStream())
NavigationStack {
SecureBackupLogoutConfirmationScreen(context: ongoingViewModel.context)
}
.previewDisplayName("Ongoing")
.snapshotPreferences(expect: ongoingViewModel.context.$viewState.map { $0.mode == .backupOngoing(progress: 0.5) })
.snapshotPreferences(expect: ongoingViewModel.context.observe(\.viewState.mode).map { $0 == .backupOngoing(progress: 0.5) }.eraseToStream())
// Uses the same view model as Waiting but with a different expectation.
NavigationStack {
SecureBackupLogoutConfirmationScreen(context: waitingViewModel.context)
}
.previewDisplayName("Stalled")
.snapshotPreferences(expect: waitingViewModel.context.$viewState.map { $0.mode == .waitingToStart(hasStalled: true) })
.snapshotPreferences(expect: waitingViewModel.context.observe(\.viewState.mode).map { $0 == .waitingToStart(hasStalled: true) }.eraseToStream())
NavigationStack {
SecureBackupLogoutConfirmationScreen(context: offlineViewModel.context)
}
.previewDisplayName("Offline")
.snapshotPreferences(expect: offlineViewModel.context.$viewState.map { $0.mode == .offline })
.snapshotPreferences(expect: offlineViewModel.context.observe(\.viewState.mode).map { $0 == .offline }.eraseToStream())
}
static func makeViewModel(mode: SecureBackupLogoutConfirmationScreenViewMode) -> SecureBackupLogoutConfirmationScreenViewModel {
@@ -8,7 +8,7 @@
import Combine
import SwiftUI
typealias SecureBackupRecoveryKeyScreenViewModelType = StateStoreViewModel<SecureBackupRecoveryKeyScreenViewState, SecureBackupRecoveryKeyScreenViewAction>
typealias SecureBackupRecoveryKeyScreenViewModelType = StateStoreViewModelV2<SecureBackupRecoveryKeyScreenViewState, SecureBackupRecoveryKeyScreenViewAction>
class SecureBackupRecoveryKeyScreenViewModel: SecureBackupRecoveryKeyScreenViewModelType, SecureBackupRecoveryKeyScreenViewModelProtocol {
private let secureBackupController: SecureBackupControllerProtocol
@@ -62,7 +62,7 @@ class SecureBackupRecoveryKeyScreenViewModel: SecureBackupRecoveryKeyScreenViewM
switch await secureBackupController.confirmRecoveryKey(state.bindings.confirmationRecoveryKey) {
case .success:
actionsSubject.send(.done(mode: context.viewState.mode))
actionsSubject.send(.done(mode: state.mode))
case .failure(let error):
MXLog.error("Failed confirming recovery key with error: \(error)")
state.bindings.alertInfo = .init(id: .init(),
@@ -80,7 +80,7 @@ class SecureBackupRecoveryKeyScreenViewModel: SecureBackupRecoveryKeyScreenViewM
message: L10n.screenRecoveryKeySetupConfirmationDescription,
primaryButton: .init(title: L10n.actionContinue) { [weak self] in
guard let self else { return }
actionsSubject.send(.done(mode: context.viewState.mode))
actionsSubject.send(.done(mode: state.mode))
},
secondaryButton: .init(title: L10n.actionCancel, role: .cancel, action: nil))
}
@@ -10,7 +10,7 @@ import Compound
import SwiftUI
struct SecureBackupRecoveryKeyScreen: View {
@ObservedObject var context: SecureBackupRecoveryKeyScreenViewModel.Context
@Bindable var context: SecureBackupRecoveryKeyScreenViewModel.Context
@FocusState private var focused
private let textFieldIdentifier = "textFieldIdentifier"
@@ -260,9 +260,7 @@ struct SecureBackupRecoveryKeyScreen_Previews: PreviewProvider, TestablePreview
NavigationStack {
SecureBackupRecoveryKeyScreen(context: setupViewModel.context)
}
.snapshotPreferences(expect: setupViewModel.context.$viewState.map { state in
state.recoveryKey != nil
})
.snapshotPreferences(expect: setupViewModel.context.observe(\.viewState.recoveryKey).map { $0 != nil }.eraseToStream())
.previewDisplayName("Set up")
NavigationStack {
@@ -8,7 +8,7 @@
import Combine
import SwiftUI
typealias SecureBackupScreenViewModelType = StateStoreViewModel<SecureBackupScreenViewState, SecureBackupScreenViewAction>
typealias SecureBackupScreenViewModelType = StateStoreViewModelV2<SecureBackupScreenViewState, SecureBackupScreenViewAction>
class SecureBackupScreenViewModel: SecureBackupScreenViewModelType, SecureBackupScreenViewModelProtocol {
private let secureBackupController: SecureBackupControllerProtocol
@@ -10,7 +10,7 @@ import Compound
import SwiftUI
struct SecureBackupScreen: View {
@ObservedObject var context: SecureBackupScreenViewModel.Context
@Bindable var context: SecureBackupScreenViewModel.Context
var body: some View {
Form {
@@ -128,33 +128,25 @@ struct SecureBackupScreen_Previews: PreviewProvider, TestablePreview {
NavigationStack {
SecureBackupScreen(context: bothSetupViewModel.context)
}
.snapshotPreferences(expect: bothSetupViewModel.context.$viewState.map { state in
state.keyBackupState == .enabled
})
.snapshotPreferences(expect: bothSetupViewModel.context.observe(\.viewState.keyBackupState).map { $0 == .enabled }.eraseToStream())
.previewDisplayName("Both setup")
NavigationStack {
SecureBackupScreen(context: onlyKeyBackupSetUpViewModel.context)
}
.snapshotPreferences(expect: onlyKeyBackupSetUpViewModel.context.$viewState.map { state in
state.keyBackupState == .enabled
})
.snapshotPreferences(expect: onlyKeyBackupSetUpViewModel.context.observe(\.viewState.keyBackupState).map { $0 == .enabled }.eraseToStream())
.previewDisplayName("Only key backup setup")
NavigationStack {
SecureBackupScreen(context: keyBackupDisabledViewModel.context)
}
.snapshotPreferences(expect: keyBackupDisabledViewModel.context.$viewState.map { state in
state.keyBackupState == .unknown
})
.snapshotPreferences(expect: keyBackupDisabledViewModel.context.observe(\.viewState.keyBackupState).map { $0 == .unknown }.eraseToStream())
.previewDisplayName("Key backup disabled")
NavigationStack {
SecureBackupScreen(context: recoveryIncompleteViewModel.context)
}
.snapshotPreferences(expect: recoveryIncompleteViewModel.context.$viewState.map { state in
state.recoveryState == .incomplete
})
.snapshotPreferences(expect: recoveryIncompleteViewModel.context.observe(\.viewState.recoveryState).map { $0 == .incomplete }.eraseToStream())
.previewDisplayName("Recovery incomplete")
}