mirror of
https://github.com/element-hq/element-android
synced 2024-09-06 08:55:23 +00:00
removing deeplink error handling as its now covered by the edit server flow instead
This commit is contained in:
parent
cdf75be0ec
commit
4cc0b81c86
|
@ -29,7 +29,6 @@ import org.matrix.android.sdk.api.failure.Failure as SdkFailure
|
|||
sealed class OnboardingViewEvents : VectorViewEvents {
|
||||
data class Loading(val message: CharSequence? = null) : OnboardingViewEvents()
|
||||
data class Failure(val throwable: Throwable) : OnboardingViewEvents()
|
||||
data class DeeplinkAuthenticationFailure(val retryAction: OnboardingAction) : OnboardingViewEvents()
|
||||
data class UnrecognisedCertificateFailure(val retryAction: OnboardingAction, val cause: SdkFailure.UnrecognizedCertificateFailure) : OnboardingViewEvents()
|
||||
|
||||
object DisplayRegistrationFallback : OnboardingViewEvents()
|
||||
|
|
|
@ -703,11 +703,6 @@ class OnboardingViewModel @AssistedInject constructor(
|
|||
when {
|
||||
error.isHomeserverUnavailable() && applicationContext.inferNoConnectivity(sdkIntProvider) -> _viewEvents.post(OnboardingViewEvents.Failure(error))
|
||||
isUnableToSelectServer(error, trigger) -> handle(OnboardingAction.PostViewEvent(OnboardingViewEvents.EditServerSelection))
|
||||
deeplinkUrlIsUnavailable(error, trigger) -> _viewEvents.post(
|
||||
OnboardingViewEvents.DeeplinkAuthenticationFailure(
|
||||
retryAction = (trigger as OnboardingAction.HomeServerChange.SelectHomeServer).resetToDefaultUrl()
|
||||
)
|
||||
)
|
||||
error.isUnrecognisedCertificate() -> {
|
||||
_viewEvents.post(OnboardingViewEvents.UnrecognisedCertificateFailure(trigger, error as Failure.UnrecognizedCertificateFailure))
|
||||
}
|
||||
|
@ -718,12 +713,6 @@ class OnboardingViewModel @AssistedInject constructor(
|
|||
private fun isUnableToSelectServer(error: Throwable, trigger: OnboardingAction.HomeServerChange) =
|
||||
trigger is OnboardingAction.HomeServerChange.SelectHomeServer && error.isHomeserverUnavailable()
|
||||
|
||||
private fun deeplinkUrlIsUnavailable(error: Throwable, trigger: OnboardingAction.HomeServerChange) = error.isHomeserverUnavailable() &&
|
||||
loginConfig != null &&
|
||||
trigger is OnboardingAction.HomeServerChange.SelectHomeServer
|
||||
|
||||
private fun OnboardingAction.HomeServerChange.SelectHomeServer.resetToDefaultUrl() = copy(homeServerUrl = defaultHomeserverUrl)
|
||||
|
||||
private suspend fun onAuthenticationStartedSuccess(
|
||||
trigger: OnboardingAction.HomeServerChange,
|
||||
config: HomeServerConnectionConfig,
|
||||
|
|
|
@ -238,7 +238,6 @@ class FtueAuthVariant(
|
|||
ensureEditServerBackstack()
|
||||
}
|
||||
OnboardingViewEvents.OpenCombinedLogin -> onStartCombinedLogin()
|
||||
is OnboardingViewEvents.DeeplinkAuthenticationFailure -> onDeeplinkedHomeserverUnavailable(viewEvents)
|
||||
OnboardingViewEvents.DisplayRegistrationFallback -> displayFallbackWebDialog()
|
||||
is OnboardingViewEvents.DisplayRegistrationStage -> doStage(viewEvents.stage)
|
||||
OnboardingViewEvents.DisplayStartRegistration -> when {
|
||||
|
@ -267,22 +266,6 @@ class FtueAuthVariant(
|
|||
}
|
||||
}
|
||||
|
||||
private fun onDeeplinkedHomeserverUnavailable(viewEvents: OnboardingViewEvents.DeeplinkAuthenticationFailure) {
|
||||
showHomeserverUnavailableDialog(onboardingViewModel.getInitialHomeServerUrl().orEmpty()) {
|
||||
onboardingViewModel.handle(OnboardingAction.ResetDeeplinkConfig)
|
||||
onboardingViewModel.handle(viewEvents.retryAction)
|
||||
}
|
||||
}
|
||||
|
||||
private fun showHomeserverUnavailableDialog(url: String, action: () -> Unit) {
|
||||
MaterialAlertDialogBuilder(activity)
|
||||
.setTitle(R.string.dialog_title_error)
|
||||
.setMessage(activity.getString(R.string.login_error_homeserver_from_url_not_found, url))
|
||||
.setPositiveButton(R.string.login_error_homeserver_from_url_not_found_enter_manual) { _, _ -> action() }
|
||||
.setNegativeButton(R.string.action_cancel, null)
|
||||
.show()
|
||||
}
|
||||
|
||||
private fun onStartCombinedLogin() {
|
||||
addRegistrationStageFragmentToBackstack(FtueAuthCombinedLoginFragment::class.java, allowStateLoss = true)
|
||||
}
|
||||
|
|
|
@ -411,27 +411,6 @@ class OnboardingViewModelTest {
|
|||
.finish()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `given unavailable deeplink, when selecting homeserver, then emits failure with default homeserver as retry action`() = runTest {
|
||||
fakeContext.givenHasConnection()
|
||||
fakeHomeServerConnectionConfigFactory.givenConfigFor(A_HOMESERVER_URL, fingerprint = null, A_HOMESERVER_CONFIG)
|
||||
fakeStartAuthenticationFlowUseCase.givenHomeserverUnavailable(A_HOMESERVER_CONFIG)
|
||||
val test = viewModel.test()
|
||||
|
||||
viewModel.handle(OnboardingAction.InitWith(LoginConfig(A_HOMESERVER_URL, null)))
|
||||
viewModel.handle(OnboardingAction.HomeServerChange.SelectHomeServer(A_HOMESERVER_URL))
|
||||
|
||||
val expectedRetryAction = OnboardingAction.HomeServerChange.SelectHomeServer("${R.string.matrix_org_server_url.toTestString()}/")
|
||||
test
|
||||
.assertStatesChanges(
|
||||
initialState,
|
||||
{ copy(isLoading = true) },
|
||||
{ copy(isLoading = false) }
|
||||
)
|
||||
.assertEvents(OnboardingViewEvents.DeeplinkAuthenticationFailure(expectedRetryAction))
|
||||
.finish()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `given in the sign up flow, when editing homeserver, then updates selected homeserver state and emits edited event`() = runTest {
|
||||
viewModelWith(initialState.copy(onboardingFlow = OnboardingFlow.SignUp))
|
||||
|
|
Loading…
Reference in a new issue