Prevent login using keyboard when homeserver is loading.

This commit is contained in:
Doug
2022-06-23 17:06:38 +01:00
committed by Doug
parent 9d81447d20
commit e32375e0db
3 changed files with 10 additions and 4 deletions

View File

@@ -66,10 +66,15 @@ struct AuthenticationLoginViewState: BindableState {
!homeserver.ssoIdentityProviders.isEmpty
}
/// `true` if it is possible to continue, otherwise `false`.
/// `true` if the username and password are ready to be submitted.
var hasValidCredentials: Bool {
!bindings.username.isEmpty && !bindings.password.isEmpty
}
/// `true` if valid credentials have been entered and the homeserver is loaded.
var canSubmit: Bool {
hasValidCredentials && !isLoading
}
}
struct AuthenticationLoginBindings {

View File

@@ -127,7 +127,7 @@ struct AuthenticationLoginScreen: View {
Text(VectorL10n.next)
}
.buttonStyle(PrimaryActionButtonStyle())
.disabled(!viewModel.viewState.hasValidCredentials || viewModel.viewState.isLoading)
.disabled(!viewModel.viewState.canSubmit)
.accessibilityIdentifier("nextButton")
}
}
@@ -166,9 +166,9 @@ struct AuthenticationLoginScreen: View {
isPasswordFocused = false
}
/// Sends the `next` view action so long as valid credentials have been input.
/// Sends the `next` view action so long as the form is ready to submit.
func submit() {
guard viewModel.viewState.hasValidCredentials else { return }
guard viewModel.viewState.canSubmit else { return }
viewModel.send(viewAction: .next)
}

View File

@@ -0,0 +1 @@
Authentication: Don't attempt to login if the user presses the return key whilst loading a homeserver parsed from a username.