From abab2a0db73c6c8b509826ed2a4decdb9203afb6 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Tue, 26 Jul 2022 11:30:34 +0100 Subject: [PATCH] including knowledge of if the session was restored when fastforwarding to the waiting for email --- .../app/features/onboarding/OnboardingViewEvents.kt | 2 +- .../app/features/onboarding/OnboardingViewModel.kt | 10 ++++++---- .../features/onboarding/ftueauth/FtueAuthVariant.kt | 8 ++++---- .../ftueauth/FtueAuthWaitForEmailFragment.kt | 3 ++- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/onboarding/OnboardingViewEvents.kt b/vector/src/main/java/im/vector/app/features/onboarding/OnboardingViewEvents.kt index ea6981a2b5..bbbf13fba9 100644 --- a/vector/src/main/java/im/vector/app/features/onboarding/OnboardingViewEvents.kt +++ b/vector/src/main/java/im/vector/app/features/onboarding/OnboardingViewEvents.kt @@ -53,7 +53,7 @@ sealed class OnboardingViewEvents : VectorViewEvents { object OnResetPasswordBreakerConfirmed : OnboardingViewEvents() object OnResetPasswordComplete : OnboardingViewEvents() - data class OnSendEmailSuccess(val email: String) : OnboardingViewEvents() + data class OnSendEmailSuccess(val email: String, val isRestoredSession: Boolean) : OnboardingViewEvents() data class OnSendMsisdnSuccess(val msisdn: String) : OnboardingViewEvents() data class OnWebLoginError(val errorCode: Int, val description: String, val failingUrl: String) : OnboardingViewEvents() diff --git a/vector/src/main/java/im/vector/app/features/onboarding/OnboardingViewModel.kt b/vector/src/main/java/im/vector/app/features/onboarding/OnboardingViewModel.kt index 52c32d88e4..8b56afa78a 100644 --- a/vector/src/main/java/im/vector/app/features/onboarding/OnboardingViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/onboarding/OnboardingViewModel.kt @@ -348,7 +348,9 @@ class OnboardingViewModel @AssistedInject constructor( overrideNextStage?.invoke() ?: _viewEvents.post(OnboardingViewEvents.DisplayStartRegistration) } RegistrationActionHandler.Result.UnsupportedStage -> _viewEvents.post(OnboardingViewEvents.DisplayRegistrationFallback) - is RegistrationActionHandler.Result.SendEmailSuccess -> _viewEvents.post(OnboardingViewEvents.OnSendEmailSuccess(it.email)) + is RegistrationActionHandler.Result.SendEmailSuccess -> _viewEvents.post( + OnboardingViewEvents.OnSendEmailSuccess(it.email, isRestoredSession = false) + ) is RegistrationActionHandler.Result.SendMsisdnSuccess -> _viewEvents.post(OnboardingViewEvents.OnSendMsisdnSuccess(it.msisdn.msisdn)) is RegistrationActionHandler.Result.Error -> _viewEvents.post(OnboardingViewEvents.Failure(it.cause)) RegistrationActionHandler.Result.MissingNextStage -> { @@ -412,8 +414,8 @@ class OnboardingViewModel @AssistedInject constructor( authenticationService.cancelPendingLoginOrRegistration() setState { copy( - isLoading = false, - registrationState = RegistrationState(), + isLoading = false, + registrationState = RegistrationState(), ) } } @@ -486,7 +488,7 @@ class OnboardingViewModel @AssistedInject constructor( try { if (registrationWizard.isRegistrationStarted()) { currentThreePid?.let { - handle(OnboardingAction.PostViewEvent(OnboardingViewEvents.OnSendEmailSuccess(it))) + handle(OnboardingAction.PostViewEvent(OnboardingViewEvents.OnSendEmailSuccess(it, isRestoredSession = true))) } } } catch (e: Throwable) { diff --git a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthVariant.kt b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthVariant.kt index 867ab45834..47be39ee17 100644 --- a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthVariant.kt +++ b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthVariant.kt @@ -196,7 +196,7 @@ class FtueAuthVariant( activity.popBackstack() } is OnboardingViewEvents.OnSendEmailSuccess -> { - openWaitForEmailVerification(viewEvents.email) + openWaitForEmailVerification(viewEvents.email, viewEvents.isRestoredSession) } is OnboardingViewEvents.OnSendMsisdnSuccess -> { openMsisdnConfirmation(viewEvents.msisdn) @@ -413,16 +413,16 @@ class FtueAuthVariant( } } - private fun openWaitForEmailVerification(email: String) { + private fun openWaitForEmailVerification(email: String, isRestoredSession: Boolean) { supportFragmentManager.popBackStack(FRAGMENT_REGISTRATION_STAGE_TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE) when { vectorFeatures.isOnboardingCombinedRegisterEnabled() -> addRegistrationStageFragmentToBackstack( FtueAuthWaitForEmailFragment::class.java, - FtueAuthWaitForEmailFragmentArgument(email), + FtueAuthWaitForEmailFragmentArgument(email, isRestoredSession), ) else -> addRegistrationStageFragmentToBackstack( FtueAuthLegacyWaitForEmailFragment::class.java, - FtueAuthWaitForEmailFragmentArgument(email), + FtueAuthWaitForEmailFragmentArgument(email, isRestoredSession), ) } } diff --git a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthWaitForEmailFragment.kt b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthWaitForEmailFragment.kt index 4649c7c799..360b204dbb 100644 --- a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthWaitForEmailFragment.kt +++ b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthWaitForEmailFragment.kt @@ -35,7 +35,8 @@ import javax.inject.Inject @Parcelize data class FtueAuthWaitForEmailFragmentArgument( - val email: String + val email: String, + val isRestoredSession: Boolean, ) : Parcelable /**