introducing a reset state for holding onto the reset inputs

This commit is contained in:
Adam Brown 2022-05-26 17:25:55 +01:00
parent a5f404f247
commit e3d46cfd15
4 changed files with 11 additions and 6 deletions

View File

@ -377,7 +377,7 @@ class OnboardingViewModel @AssistedInject constructor(
setState { setState {
copy( copy(
isLoading = false, isLoading = false,
resetPasswordEmail = null resetState = ResetState()
) )
} }
} }
@ -466,7 +466,7 @@ class OnboardingViewModel @AssistedInject constructor(
setState { setState {
copy( copy(
isLoading = false, isLoading = false,
resetPasswordEmail = action.email resetState = ResetState(email = action.email)
) )
} }
@ -495,7 +495,7 @@ class OnboardingViewModel @AssistedInject constructor(
setState { setState {
copy( copy(
isLoading = false, isLoading = false,
resetPasswordEmail = null resetState = ResetState()
) )
} }

View File

@ -39,7 +39,7 @@ data class OnboardingViewState(
@PersistState @PersistState
val signMode: SignMode = SignMode.Unknown, val signMode: SignMode = SignMode.Unknown,
@PersistState @PersistState
val resetPasswordEmail: String? = null, val resetState: ResetState = ResetState(),
// For SSO session recovery // For SSO session recovery
@PersistState @PersistState
@ -84,6 +84,11 @@ data class PersonalizationState(
fun supportsPersonalization() = supportsChangingDisplayName || supportsChangingProfilePicture fun supportsPersonalization() = supportsChangingDisplayName || supportsChangingProfilePicture
} }
@Parcelize
data class ResetState(
val email: String? = null
) : Parcelable
@Parcelize @Parcelize
data class SelectedAuthenticationState( data class SelectedAuthenticationState(
val description: AuthenticationDescription? = null, val description: AuthenticationDescription? = null,

View File

@ -153,7 +153,7 @@ abstract class AbstractFtueAuthFragment<VB : ViewBinding> : VectorBaseFragment<V
final override fun invalidate() = withState(viewModel) { state -> final override fun invalidate() = withState(viewModel) { state ->
// True when email is sent with success to the homeserver // True when email is sent with success to the homeserver
isResetPasswordStarted = state.resetPasswordEmail.isNullOrBlank().not() isResetPasswordStarted = state.resetState.email.isNullOrBlank().not()
updateWithState(state) updateWithState(state)
} }

View File

@ -44,7 +44,7 @@ class FtueAuthResetPasswordMailConfirmationFragment @Inject constructor() : Abst
} }
private fun setupUi(state: OnboardingViewState) { private fun setupUi(state: OnboardingViewState) {
views.resetPasswordMailConfirmationNotice.text = getString(R.string.login_reset_password_mail_confirmation_notice, state.resetPasswordEmail) views.resetPasswordMailConfirmationNotice.text = getString(R.string.login_reset_password_mail_confirmation_notice, state.resetState.email)
} }
private fun submit() { private fun submit() {