Automatically sign out when toggling the SSS feature flag. (#3071)

This commit is contained in:
Doug
2024-07-23 11:55:51 +01:00
committed by GitHub
parent 9879552b46
commit bf22250b45
14 changed files with 43 additions and 14 deletions
@@ -19,6 +19,8 @@ import SwiftUI
enum DeveloperOptionsScreenCoordinatorAction {
case clearCache
/// Logout without a confirmation to avoid losing keys when trying SSS.
case forceLogout
}
final class DeveloperOptionsScreenCoordinator: CoordinatorProtocol {
@@ -42,6 +44,8 @@ final class DeveloperOptionsScreenCoordinator: CoordinatorProtocol {
switch action {
case .clearCache:
actionsSubject.send(.clearCache)
case .forceLogout:
actionsSubject.send(.forceLogout)
}
}
.store(in: &cancellables)
@@ -18,6 +18,8 @@ import Foundation
enum DeveloperOptionsScreenViewModelAction {
case clearCache
/// Logout without a confirmation to avoid losing keys when trying SSS.
case forceLogout
}
struct DeveloperOptionsScreenViewState: BindableState {
@@ -31,6 +31,16 @@ class DeveloperOptionsScreenViewModel: DeveloperOptionsScreenViewModelType, Deve
let state = DeveloperOptionsScreenViewState(elementCallBaseURL: elementCallBaseURL, bindings: bindings)
super.init(initialViewState: state)
context.$viewState
.map(\.bindings.simplifiedSlidingSyncEnabled)
.removeDuplicates()
.dropFirst() // Ignore the initial value received when opening the screen.
.sink { [weak self] isEnabled in
MXLog.error("Toggled simplifiedSlidingSyncEnabled: \(isEnabled). Signing out.")
self?.actionsSubject.send(.forceLogout)
}
.store(in: &cancellables)
}
override func process(viewAction: DeveloperOptionsScreenViewAction) {
@@ -30,7 +30,7 @@ struct DeveloperOptionsScreen: View {
Section("Sliding Sync") {
Toggle(isOn: $context.simplifiedSlidingSyncEnabled) {
Text("Simplified Sliding Sync")
Text("Requires app reboot")
Text("When toggled you'll be logged out of the app and will need to log in again.")
}
}