fixing reset fragments not removing previous screens when moving to the next step

This commit is contained in:
Adam Brown 2022-06-07 17:18:18 +01:00
parent 3c03bae4c5
commit 7ef8193a93

View file

@ -163,35 +163,24 @@ class FtueAuthVariant(
is OnboardingViewEvents.OnWebLoginError -> onWebLoginError(viewEvents) is OnboardingViewEvents.OnWebLoginError -> onWebLoginError(viewEvents)
is OnboardingViewEvents.OnForgetPasswordClicked -> is OnboardingViewEvents.OnForgetPasswordClicked ->
when { when {
vectorFeatures.isOnboardingCombinedLoginEnabled() -> activity.addFragmentToBackstack( vectorFeatures.isOnboardingCombinedLoginEnabled() -> addLoginStageFragmentToBackstack(FtueAuthResetPasswordEmailEntryFragment::class.java)
views.loginFragmentContainer, else -> addLoginStageFragmentToBackstack(FtueAuthResetPasswordFragment::class.java)
FtueAuthResetPasswordEmailEntryFragment::class.java,
option = commonOption
)
else -> activity.addFragmentToBackstack(
views.loginFragmentContainer,
FtueAuthResetPasswordFragment::class.java,
option = commonOption
)
} }
is OnboardingViewEvents.OnResetPasswordSendThreePidDone -> { is OnboardingViewEvents.OnResetPasswordSendThreePidDone -> {
supportFragmentManager.popBackStack(FRAGMENT_LOGIN_TAG, POP_BACK_STACK_EXCLUSIVE) supportFragmentManager.popBackStack(FRAGMENT_LOGIN_TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE)
when { when {
vectorFeatures.isOnboardingCombinedLoginEnabled() -> activity.addFragmentToBackstack( vectorFeatures.isOnboardingCombinedLoginEnabled() -> addLoginStageFragmentToBackstack(
views.loginFragmentContainer,
FtueAuthResetPasswordBreakerFragment::class.java, FtueAuthResetPasswordBreakerFragment::class.java,
FtueAuthResetPasswordBreakerArgument(viewEvents.email), FtueAuthResetPasswordBreakerArgument(viewEvents.email),
option = commonOption
) )
else -> activity.addFragmentToBackstack( else -> activity.addFragmentToBackstack(
views.loginFragmentContainer, views.loginFragmentContainer,
FtueAuthResetPasswordMailConfirmationFragment::class.java, FtueAuthResetPasswordMailConfirmationFragment::class.java,
option = commonOption
) )
} }
} }
OnboardingViewEvents.OnResetPasswordBreakerConfirmed -> { OnboardingViewEvents.OnResetPasswordBreakerConfirmed -> {
supportFragmentManager.popBackStack(FRAGMENT_LOGIN_TAG, POP_BACK_STACK_EXCLUSIVE) supportFragmentManager.popBackStack(FRAGMENT_LOGIN_TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE)
activity.addFragmentToBackstack( activity.addFragmentToBackstack(
views.loginFragmentContainer, views.loginFragmentContainer,
FtueAuthResetPasswordEntryFragment::class.java, FtueAuthResetPasswordEntryFragment::class.java,
@ -199,16 +188,12 @@ class FtueAuthVariant(
) )
} }
is OnboardingViewEvents.OnResetPasswordMailConfirmationSuccess -> { is OnboardingViewEvents.OnResetPasswordMailConfirmationSuccess -> {
supportFragmentManager.popBackStack(FRAGMENT_LOGIN_TAG, POP_BACK_STACK_EXCLUSIVE) supportFragmentManager.popBackStack(FRAGMENT_LOGIN_TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE)
activity.addFragmentToBackstack( addLoginStageFragmentToBackstack(FtueAuthResetPasswordSuccessFragment::class.java)
views.loginFragmentContainer,
FtueAuthResetPasswordSuccessFragment::class.java,
option = commonOption
)
} }
is OnboardingViewEvents.OnResetPasswordMailConfirmationSuccessDone -> { is OnboardingViewEvents.OnResetPasswordMailConfirmationSuccessDone -> {
// Go back to the login fragment // Go back to the login fragment
supportFragmentManager.popBackStack(FRAGMENT_LOGIN_TAG, POP_BACK_STACK_EXCLUSIVE) supportFragmentManager.popBackStack(FRAGMENT_LOGIN_TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE)
} }
is OnboardingViewEvents.OnSendEmailSuccess -> { is OnboardingViewEvents.OnSendEmailSuccess -> {
openWaitForEmailVerification(viewEvents.email) openWaitForEmailVerification(viewEvents.email)
@ -519,4 +504,14 @@ class FtueAuthVariant(
option = commonOption option = commonOption
) )
} }
private fun addLoginStageFragmentToBackstack(fragmentClass: Class<out Fragment>, params: Parcelable? = null) {
activity.addFragmentToBackstack(
views.loginFragmentContainer,
fragmentClass,
params,
tag = FRAGMENT_LOGIN_TAG,
option = commonOption
)
}
} }