From f9c35e6bcba071b544cc46d06cd0be002a46904a Mon Sep 17 00:00:00 2001 From: Onuray Sahin Date: Tue, 6 Oct 2020 11:15:00 +0300 Subject: [PATCH 1/2] If there is a pending email validation continue on this step --- CHANGES.md | 1 + .../im/vector/app/features/login/LoginAction.kt | 2 +- .../im/vector/app/features/login/LoginActivity.kt | 14 +++++++------- .../im/vector/app/features/login/LoginViewModel.kt | 7 +++++++ 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 754fb35612..697aa17b35 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -10,6 +10,7 @@ Improvements 🙌: - Small optimisation of scrolling experience in timeline (#2114) - Allow user to reset cross signing if he has no way to recover (#2052) - Create home shortcut for any room (#1525) + - Can't confirm email due to killing by Android (#2021) Bugfix 🐛: - Improve support for image/audio/video/file selection with intent changes (#1376) diff --git a/vector/src/main/java/im/vector/app/features/login/LoginAction.kt b/vector/src/main/java/im/vector/app/features/login/LoginAction.kt index 9067984852..9788060ad3 100644 --- a/vector/src/main/java/im/vector/app/features/login/LoginAction.kt +++ b/vector/src/main/java/im/vector/app/features/login/LoginAction.kt @@ -27,7 +27,7 @@ sealed class LoginAction : VectorViewModelAction { data class UpdateSignMode(val signMode: SignMode) : LoginAction() data class LoginWithToken(val loginToken: String) : LoginAction() data class WebLoginSuccess(val credentials: Credentials) : LoginAction() - data class InitWith(val loginConfig: LoginConfig) : LoginAction() + data class InitWith(val loginConfig: LoginConfig?) : LoginAction() data class ResetPassword(val email: String, val newPassword: String) : LoginAction() object ResetPasswordMailConfirmed : LoginAction() diff --git a/vector/src/main/java/im/vector/app/features/login/LoginActivity.kt b/vector/src/main/java/im/vector/app/features/login/LoginActivity.kt index 0eb4ef3e32..01e835b4e3 100644 --- a/vector/src/main/java/im/vector/app/features/login/LoginActivity.kt +++ b/vector/src/main/java/im/vector/app/features/login/LoginActivity.kt @@ -91,19 +91,19 @@ open class LoginActivity : VectorBaseActivity(), ToolbarConfigurable, UnlockedAc addFirstFragment() } - // Get config extra - val loginConfig = intent.getParcelableExtra(EXTRA_CONFIG) - if (loginConfig != null && isFirstCreation()) { - // TODO Check this - loginViewModel.handle(LoginAction.InitWith(loginConfig)) - } - loginViewModel .subscribe(this) { updateWithState(it) } loginViewModel.observeViewEvents { handleLoginViewEvents(it) } + + // Get config extra + val loginConfig = intent.getParcelableExtra(EXTRA_CONFIG) + if (isFirstCreation()) { + // TODO Check this + loginViewModel.handle(LoginAction.InitWith(loginConfig)) + } } protected open fun addFirstFragment() { diff --git a/vector/src/main/java/im/vector/app/features/login/LoginViewModel.kt b/vector/src/main/java/im/vector/app/features/login/LoginViewModel.kt index f986227961..dc513d1666 100644 --- a/vector/src/main/java/im/vector/app/features/login/LoginViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/login/LoginViewModel.kt @@ -417,6 +417,13 @@ class LoginViewModel @AssistedInject constructor( private fun handleInitWith(action: LoginAction.InitWith) { loginConfig = action.loginConfig + + // If there is a pending email validation continue on this step + currentThreePid?.let { + if (isRegistrationStarted) { + handle(LoginAction.PostViewEvent(LoginViewEvents.OnSendEmailSuccess(it))) + } + } } private fun handleResetPassword(action: LoginAction.ResetPassword) { From 3877b2f58ea3b39cc5b5d3590dcc5a7b403475c4 Mon Sep 17 00:00:00 2001 From: Onuray Sahin Date: Tue, 6 Oct 2020 17:02:49 +0300 Subject: [PATCH 2/2] Delete pending session store and states after session is created. --- CHANGES.md | 1 + .../im/vector/app/features/login/LoginViewModel.kt | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 85eb76f5f2..d2767d0174 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -17,6 +17,7 @@ Improvements 🙌: Bugfix 🐛: - Improve support for image/audio/video/file selection with intent changes (#1376) - Fix Splash layout on small screens + - Invalid popup when pressing back (#1635) Translations 🗣: - diff --git a/vector/src/main/java/im/vector/app/features/login/LoginViewModel.kt b/vector/src/main/java/im/vector/app/features/login/LoginViewModel.kt index dc513d1666..81d6a78123 100644 --- a/vector/src/main/java/im/vector/app/features/login/LoginViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/login/LoginViewModel.kt @@ -419,10 +419,15 @@ class LoginViewModel @AssistedInject constructor( loginConfig = action.loginConfig // If there is a pending email validation continue on this step - currentThreePid?.let { - if (isRegistrationStarted) { - handle(LoginAction.PostViewEvent(LoginViewEvents.OnSendEmailSuccess(it))) + try { + if (registrationWizard?.isRegistrationStarted == true) { + currentThreePid?.let { + handle(LoginAction.PostViewEvent(LoginViewEvents.OnSendEmailSuccess(it))) + } } + } catch (e: Throwable) { + // NOOP. API is designed to use wizards in a login/registration flow, + // but we need to check the state anyway. } } @@ -679,6 +684,7 @@ class LoginViewModel @AssistedInject constructor( private fun onSessionCreated(session: Session) { activeSessionHolder.setActiveSession(session) + authenticationService.reset() session.configureAndStart(applicationContext) setState { copy( @@ -747,7 +753,7 @@ class LoginViewModel @AssistedInject constructor( override fun onSuccess(data: LoginFlowResult) { when (data) { - is LoginFlowResult.Success -> { + is LoginFlowResult.Success -> { val loginMode = when { // SSO login is taken first data.supportedLoginTypes.contains(LoginFlowTypes.SSO) -> LoginMode.Sso