removing ability to shortcut registration to waiting for email if the app is destroyed

- this behaviour puts the app in an invalid state as we've lost all the ViewState we've collect from the previous onboarding steps
- the app already handles restoring the onboarding state via the system restoration
This commit is contained in:
Adam Brown 2022-08-17 11:38:30 +01:00
parent 9a5b21d8f1
commit 1d03460aee
2 changed files with 1 additions and 30 deletions

View File

@ -71,7 +71,7 @@ import java.util.concurrent.CancellationException
*
*/
class OnboardingViewModel @AssistedInject constructor(
@Assisted initialState: OnboardingViewState,
@Assisted private val initialState: OnboardingViewState,
private val applicationContext: Context,
private val authenticationService: AuthenticationService,
private val activeSessionHolder: ActiveSessionHolder,
@ -123,9 +123,6 @@ class OnboardingViewModel @AssistedInject constructor(
private val registrationWizard: RegistrationWizard
get() = authenticationService.getRegistrationWizard()
val currentThreePid: String?
get() = registrationWizard.getCurrentThreePid()
// True when login and password has been sent with success to the homeserver
val isRegistrationStarted: Boolean
get() = authenticationService.isRegistrationStarted()
@ -492,17 +489,6 @@ class OnboardingViewModel @AssistedInject constructor(
private fun handleInitWith(action: OnboardingAction.InitWith) {
loginConfig = action.loginConfig
// If there is a pending email validation continue on this step
try {
if (registrationWizard.isRegistrationStarted()) {
currentThreePid?.let {
handle(OnboardingAction.PostViewEvent(OnboardingViewEvents.OnSendEmailSuccess(it, isRestoredSession = true)))
}
}
} catch (e: Throwable) {
// NOOP. API is designed to use wizards in a login/registration flow,
// but we need to check the state anyway.
}
}
private fun handleResetPassword(action: OnboardingAction.ResetPassword) {

View File

@ -191,21 +191,6 @@ class OnboardingViewModelTest {
.finish()
}
@Test
fun `given registration started with currentThreePid, when handling InitWith, then emits restored session OnSendEmailSuccess`() = runTest {
val test = viewModel.test()
fakeAuthenticationService.givenRegistrationWizard(FakeRegistrationWizard().also {
it.givenRegistrationStarted(hasStarted = true)
it.givenCurrentThreePid(AN_EMAIL)
})
viewModel.handle(OnboardingAction.InitWith(LoginConfig(A_HOMESERVER_URL, identityServerUrl = null)))
test
.assertEvents(OnboardingViewEvents.OnSendEmailSuccess(AN_EMAIL, isRestoredSession = true))
.finish()
}
@Test
fun `given registration not started, when handling InitWith, then does nothing`() = runTest {
val test = viewModel.test()