mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
Adopt sliding sync discovery for authentication.
This commit is contained in:
+3
-6
@@ -19,8 +19,6 @@ import SwiftUI
|
||||
|
||||
enum DeveloperOptionsScreenCoordinatorAction {
|
||||
case clearCache
|
||||
/// Logout without a confirmation to avoid losing keys when trying SSS.
|
||||
case forceLogout
|
||||
}
|
||||
|
||||
final class DeveloperOptionsScreenCoordinator: CoordinatorProtocol {
|
||||
@@ -33,9 +31,10 @@ final class DeveloperOptionsScreenCoordinator: CoordinatorProtocol {
|
||||
actionsSubject.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
init() {
|
||||
init(isUsingNativeSlidingSync: Bool) {
|
||||
viewModel = DeveloperOptionsScreenViewModel(developerOptions: ServiceLocator.shared.settings,
|
||||
elementCallBaseURL: ServiceLocator.shared.settings.elementCallBaseURL)
|
||||
elementCallBaseURL: ServiceLocator.shared.settings.elementCallBaseURL,
|
||||
isUsingNativeSlidingSync: isUsingNativeSlidingSync)
|
||||
|
||||
viewModel.actions
|
||||
.sink { [weak self] action in
|
||||
@@ -44,8 +43,6 @@ final class DeveloperOptionsScreenCoordinator: CoordinatorProtocol {
|
||||
switch action {
|
||||
case .clearCache:
|
||||
actionsSubject.send(.clearCache)
|
||||
case .forceLogout:
|
||||
actionsSubject.send(.forceLogout)
|
||||
}
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
+6
-3
@@ -18,13 +18,16 @@ import Foundation
|
||||
|
||||
enum DeveloperOptionsScreenViewModelAction {
|
||||
case clearCache
|
||||
/// Logout without a confirmation to avoid losing keys when trying SSS.
|
||||
case forceLogout
|
||||
}
|
||||
|
||||
struct DeveloperOptionsScreenViewState: BindableState {
|
||||
let elementCallBaseURL: URL
|
||||
let isUsingNativeSlidingSync: Bool
|
||||
var bindings: DeveloperOptionsScreenViewStateBindings
|
||||
|
||||
var slidingSyncFooter: String {
|
||||
"The method used to configure sliding sync when signing in. Changing this setting has no effect until you sign out.\n\nYour current session is using \(isUsingNativeSlidingSync ? "native sliding sync." : "a sliding sync proxy.")"
|
||||
}
|
||||
}
|
||||
|
||||
// periphery: ignore - subscripts are seen as false positive
|
||||
@@ -48,7 +51,7 @@ enum DeveloperOptionsScreenViewAction {
|
||||
|
||||
protocol DeveloperOptionsProtocol: AnyObject {
|
||||
var logLevel: TracingConfiguration.LogLevel { get set }
|
||||
var simplifiedSlidingSyncEnabled: Bool { get set }
|
||||
var slidingSyncDiscovery: AppSettings.SlidingSyncDiscovery { get set }
|
||||
var hideUnreadMessagesBadge: Bool { get set }
|
||||
var elementCallBaseURLOverride: URL? { get set }
|
||||
var fuzzyRoomListSearchEnabled: Bool { get set }
|
||||
|
||||
+2
-12
@@ -26,21 +26,11 @@ class DeveloperOptionsScreenViewModel: DeveloperOptionsScreenViewModelType, Deve
|
||||
actionsSubject.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
init(developerOptions: DeveloperOptionsProtocol, elementCallBaseURL: URL) {
|
||||
init(developerOptions: DeveloperOptionsProtocol, elementCallBaseURL: URL, isUsingNativeSlidingSync: Bool) {
|
||||
let bindings = DeveloperOptionsScreenViewStateBindings(developerOptions: developerOptions)
|
||||
let state = DeveloperOptionsScreenViewState(elementCallBaseURL: elementCallBaseURL, bindings: bindings)
|
||||
let state = DeveloperOptionsScreenViewState(elementCallBaseURL: elementCallBaseURL, isUsingNativeSlidingSync: isUsingNativeSlidingSync, 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) {
|
||||
|
||||
+11
-5
@@ -32,11 +32,16 @@ struct DeveloperOptionsScreen: View {
|
||||
LogLevelConfigurationView(logLevel: $context.logLevel)
|
||||
}
|
||||
|
||||
Section("Sliding Sync") {
|
||||
Toggle(isOn: $context.simplifiedSlidingSyncEnabled) {
|
||||
Text("Simplified Sliding Sync")
|
||||
Text("When toggled you'll be logged out of the app and will need to log in again.")
|
||||
Section {
|
||||
Picker("Discovery", selection: $context.slidingSyncDiscovery) {
|
||||
Text("Proxy only").tag(AppSettings.SlidingSyncDiscovery.proxy)
|
||||
Text("Automatic").tag(AppSettings.SlidingSyncDiscovery.native)
|
||||
Text("Force Native ⚠️").tag(AppSettings.SlidingSyncDiscovery.forceNative)
|
||||
}
|
||||
} header: {
|
||||
Text("Sliding Sync")
|
||||
} footer: {
|
||||
Text(context.viewState.slidingSyncFooter)
|
||||
}
|
||||
|
||||
Section("Message Pinning") {
|
||||
@@ -174,7 +179,8 @@ private struct LogLevelConfigurationView: View {
|
||||
|
||||
struct DeveloperOptionsScreen_Previews: PreviewProvider {
|
||||
static let viewModel = DeveloperOptionsScreenViewModel(developerOptions: ServiceLocator.shared.settings,
|
||||
elementCallBaseURL: ServiceLocator.shared.settings.elementCallBaseURL)
|
||||
elementCallBaseURL: ServiceLocator.shared.settings.elementCallBaseURL,
|
||||
isUsingNativeSlidingSync: true)
|
||||
static var previews: some View {
|
||||
NavigationStack {
|
||||
DeveloperOptionsScreen(context: viewModel.context)
|
||||
|
||||
Reference in New Issue
Block a user