mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
Ignore repeated confirms on the server selection screen
Tapping Continue and then the keyboard's Done key (or double tapping Continue) started two server configurations. With a password-only server both asked the flow to show the login screen, and the second request hit the authentication state machine's unexpected transition fatalError. Keep the running confirmation task and ignore further confirms until it finishes, so the flow continues once. The guard clears afterwards so confirming again after going back from the login screen still works. Fixes ELEMENT-X-IOS-XED
This commit is contained in:
+11
-5
@@ -20,6 +20,8 @@ class ServerSelectionScreenViewModel: ServerSelectionScreenViewModelType, Server
|
||||
|
||||
/// Debounces autocompletion from user input
|
||||
private var debouncedAutocompleteTask: Task<Void, Never>?
|
||||
/// The confirmation in progress, used to ignore repeated confirms (e.g. Continue then keyboard Done).
|
||||
private var confirmTask: Task<Void, Never>?
|
||||
|
||||
private var actionsSubject: PassthroughSubject<ServerSelectionScreenViewModelAction, Never> = .init()
|
||||
|
||||
@@ -65,11 +67,15 @@ class ServerSelectionScreenViewModel: ServerSelectionScreenViewModelType, Server
|
||||
guard state.textField != textField else { return } // stop the infinite loop
|
||||
state.textField = textField
|
||||
case .confirm:
|
||||
switch state.mode {
|
||||
case .userInput:
|
||||
Task { await configureHomeserver() }
|
||||
case .picker:
|
||||
Task { await pickServer() }
|
||||
guard confirmTask == nil else { return }
|
||||
confirmTask = Task {
|
||||
switch state.mode {
|
||||
case .userInput:
|
||||
await configureHomeserver()
|
||||
case .picker:
|
||||
await pickServer()
|
||||
}
|
||||
confirmTask = nil
|
||||
}
|
||||
case .clearFooterError:
|
||||
clearFooterError()
|
||||
|
||||
Reference in New Issue
Block a user