mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-05 11:58:32 +00:00
Automatic discovery of the sliding sync proxy. (#535)
* Automatic discovery of the sliding sync proxy. * Handle homeserver detection from a MXID. * Update sliding sync info link, SDK and bump patch. Add a migration on the new version. The change in restoration token format requires the user to sign in again, but this will fail with the existing device ID.
This commit is contained in:
@@ -124,6 +124,8 @@ final class LoginCoordinator: CoordinatorProtocol {
|
||||
viewModel.displayError(.alert(ElementL10n.authInvalidLoginParam))
|
||||
case .accountDeactivated:
|
||||
viewModel.displayError(.alert(ElementL10n.authInvalidLoginDeactivatedAccount))
|
||||
case .slidingSyncNotAvailable:
|
||||
viewModel.displayError(.slidingSyncAlert)
|
||||
default:
|
||||
viewModel.displayError(.alert(ElementL10n.unknownError))
|
||||
}
|
||||
@@ -197,10 +199,8 @@ final class LoginCoordinator: CoordinatorProtocol {
|
||||
|
||||
/// Presents the server selection screen as a modal.
|
||||
private func presentServerSelectionScreen() {
|
||||
let userNotificationController = UserNotificationController(rootCoordinator: navigationStackCoordinator)
|
||||
|
||||
let parameters = ServerSelectionCoordinatorParameters(authenticationService: authenticationService,
|
||||
userNotificationController: userNotificationController,
|
||||
userNotificationController: ServiceLocator.shared.userNotificationController,
|
||||
isModallyPresented: false)
|
||||
|
||||
let coordinator = ServerSelectionCoordinator(parameters: parameters)
|
||||
|
||||
@@ -94,6 +94,8 @@ enum LoginErrorType: Hashable {
|
||||
case alert(String)
|
||||
/// Looking up the homeserver from the username failed.
|
||||
case invalidHomeserver
|
||||
/// An alert that allows the user to learn about sliding sync.
|
||||
case slidingSyncAlert
|
||||
/// The response from the homeserver was unexpected.
|
||||
case unknown
|
||||
}
|
||||
|
||||
@@ -62,6 +62,16 @@ class LoginViewModel: LoginViewModelType, LoginViewModelProtocol {
|
||||
state.bindings.alertInfo = AlertInfo(id: type,
|
||||
title: ElementL10n.dialogTitleError,
|
||||
message: ElementL10n.loginSigninMatrixIdErrorInvalidMatrixId)
|
||||
case .slidingSyncAlert:
|
||||
let openURL = { UIApplication.shared.open(ServiceLocator.shared.settings.slidingSyncLearnMoreURL) }
|
||||
state.bindings.alertInfo = AlertInfo(id: .slidingSyncAlert,
|
||||
title: ElementL10n.serverSelectionSlidingSyncAlertTitle,
|
||||
message: ElementL10n.serverSelectionSlidingSyncAlertMessage,
|
||||
primaryButton: .init(title: ElementL10n.actionLearnMore, role: .cancel, action: openURL),
|
||||
secondaryButton: .init(title: ElementL10n.actionCancel, action: nil))
|
||||
|
||||
// Clear out the invalid username to avoid an attempted login to matrix.org
|
||||
state.bindings.username = ""
|
||||
case .unknown:
|
||||
state.bindings.alertInfo = AlertInfo(id: type)
|
||||
}
|
||||
|
||||
@@ -64,7 +64,6 @@ struct LoginScreen: View {
|
||||
LoginServerInfoSection(address: context.viewState.homeserver.address) {
|
||||
context.send(viewAction: .selectServer)
|
||||
}
|
||||
.disabled(true) // The button is disabled for this demo.
|
||||
}
|
||||
|
||||
/// The form with text fields for username and password, along with a submit button.
|
||||
@@ -96,14 +95,6 @@ struct LoginScreen: View {
|
||||
.onSubmit(submit)
|
||||
.accessibilityIdentifier("passwordTextField")
|
||||
|
||||
// uncomment this piece of code once forgot password will be available
|
||||
// Button { context.send(viewAction: .forgotPassword) } label: {
|
||||
// Text(ElementL10n.ftueAuthForgotPassword)
|
||||
// .font(.element.body)
|
||||
// }
|
||||
// .frame(maxWidth: .infinity, alignment: .trailing)
|
||||
// .padding(.bottom, 8)
|
||||
|
||||
Spacer().frame(height: 32)
|
||||
|
||||
Button(action: submit) {
|
||||
|
||||
@@ -48,7 +48,6 @@ struct LoginServerInfoSection: View {
|
||||
Image(systemName: "chevron.right")
|
||||
.foregroundColor(.element.tertiaryContent)
|
||||
.padding(.trailing, 16)
|
||||
.hidden() // The button is disabled for this demo.
|
||||
}
|
||||
.background(RoundedRectangle(cornerRadius: 14).fill(Color.element.system))
|
||||
}
|
||||
|
||||
+2
@@ -102,6 +102,8 @@ final class ServerSelectionCoordinator: CoordinatorProtocol {
|
||||
switch error {
|
||||
case .invalidServer, .invalidHomeserverAddress:
|
||||
viewModel.displayError(.footerMessage(ElementL10n.loginErrorHomeserverNotFound))
|
||||
case .slidingSyncNotAvailable:
|
||||
viewModel.displayError(.slidingSyncAlert)
|
||||
default:
|
||||
viewModel.displayError(.footerMessage(ElementL10n.unknownError))
|
||||
}
|
||||
|
||||
@@ -71,4 +71,6 @@ enum ServerSelectionViewAction {
|
||||
enum ServerSelectionErrorType: Hashable {
|
||||
/// An error message to be shown in the text field footer.
|
||||
case footerMessage(String)
|
||||
/// An alert that allows the user to learn about sliding sync.
|
||||
case slidingSyncAlert
|
||||
}
|
||||
|
||||
@@ -45,6 +45,13 @@ class ServerSelectionViewModel: ServerSelectionViewModelType, ServerSelectionVie
|
||||
withElementAnimation {
|
||||
state.footerErrorMessage = message
|
||||
}
|
||||
case .slidingSyncAlert:
|
||||
let openURL = { UIApplication.shared.open(ServiceLocator.shared.settings.slidingSyncLearnMoreURL) }
|
||||
state.bindings.alertInfo = AlertInfo(id: .slidingSyncAlert,
|
||||
title: ElementL10n.serverSelectionSlidingSyncAlertTitle,
|
||||
message: ElementL10n.serverSelectionSlidingSyncAlertMessage,
|
||||
primaryButton: .init(title: ElementL10n.actionLearnMore, role: .cancel, action: openURL),
|
||||
secondaryButton: .init(title: ElementL10n.actionCancel, action: nil))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user