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:
parent
9a5b21d8f1
commit
1d03460aee
@ -71,7 +71,7 @@ import java.util.concurrent.CancellationException
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class OnboardingViewModel @AssistedInject constructor(
|
class OnboardingViewModel @AssistedInject constructor(
|
||||||
@Assisted initialState: OnboardingViewState,
|
@Assisted private val initialState: OnboardingViewState,
|
||||||
private val applicationContext: Context,
|
private val applicationContext: Context,
|
||||||
private val authenticationService: AuthenticationService,
|
private val authenticationService: AuthenticationService,
|
||||||
private val activeSessionHolder: ActiveSessionHolder,
|
private val activeSessionHolder: ActiveSessionHolder,
|
||||||
@ -123,9 +123,6 @@ class OnboardingViewModel @AssistedInject constructor(
|
|||||||
private val registrationWizard: RegistrationWizard
|
private val registrationWizard: RegistrationWizard
|
||||||
get() = authenticationService.getRegistrationWizard()
|
get() = authenticationService.getRegistrationWizard()
|
||||||
|
|
||||||
val currentThreePid: String?
|
|
||||||
get() = registrationWizard.getCurrentThreePid()
|
|
||||||
|
|
||||||
// True when login and password has been sent with success to the homeserver
|
// True when login and password has been sent with success to the homeserver
|
||||||
val isRegistrationStarted: Boolean
|
val isRegistrationStarted: Boolean
|
||||||
get() = authenticationService.isRegistrationStarted()
|
get() = authenticationService.isRegistrationStarted()
|
||||||
@ -492,17 +489,6 @@ class OnboardingViewModel @AssistedInject constructor(
|
|||||||
|
|
||||||
private fun handleInitWith(action: OnboardingAction.InitWith) {
|
private fun handleInitWith(action: OnboardingAction.InitWith) {
|
||||||
loginConfig = action.loginConfig
|
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) {
|
private fun handleResetPassword(action: OnboardingAction.ResetPassword) {
|
||||||
|
@ -191,21 +191,6 @@ class OnboardingViewModelTest {
|
|||||||
.finish()
|
.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
|
@Test
|
||||||
fun `given registration not started, when handling InitWith, then does nothing`() = runTest {
|
fun `given registration not started, when handling InitWith, then does nothing`() = runTest {
|
||||||
val test = viewModel.test()
|
val test = viewModel.test()
|
||||||
|
Loading…
Reference in New Issue
Block a user