diff --git a/app/src/main/java/org/permanent/permanent/ui/login/AuthenticationFragment.kt b/app/src/main/java/org/permanent/permanent/ui/login/AuthenticationFragment.kt index d09cba63..a0aaea48 100644 --- a/app/src/main/java/org/permanent/permanent/ui/login/AuthenticationFragment.kt +++ b/app/src/main/java/org/permanent/permanent/ui/login/AuthenticationFragment.kt @@ -88,11 +88,14 @@ class AuthenticationFragment : PermanentBaseFragment() { private val onAccountCreated = Observer { logSignUpEvents() - startActivity(Intent(context, ArchiveOnboardingActivity::class.java)) - activity?.finish() + startArchiveOnboardingActivity() } private val userMissingDefaultArchiveObserver = Observer { + startArchiveOnboardingActivity() + } + + private fun startArchiveOnboardingActivity() { startActivity(Intent(context, ArchiveOnboardingActivity::class.java)) activity?.finish() } diff --git a/app/src/main/java/org/permanent/permanent/viewmodels/AuthenticationViewModel.kt b/app/src/main/java/org/permanent/permanent/viewmodels/AuthenticationViewModel.kt index d1c0eba3..f1008747 100644 --- a/app/src/main/java/org/permanent/permanent/viewmodels/AuthenticationViewModel.kt +++ b/app/src/main/java/org/permanent/permanent/viewmodels/AuthenticationViewModel.kt @@ -102,7 +102,6 @@ class AuthenticationViewModel(application: Application) : ObservableAndroidViewM authRepository.login(email, password, object : IAuthenticationRepository.IOnLoginListener { override fun onSuccess() { _isBusyState.value = false - prefsHelper.saveUserLoggedIn(true) val defaultArchiveId = prefsHelper.getDefaultArchiveId() if (defaultArchiveId == 0) { @@ -155,6 +154,7 @@ class AuthenticationViewModel(application: Application) : ObservableAndroidViewM archive.thumbURL200, archive.accessRole ) + prefsHelper.saveUserLoggedIn(true) onSignedIn.call() return } @@ -210,7 +210,7 @@ class AuthenticationViewModel(application: Application) : ObservableAndroidViewM object : IAuthenticationRepository.IOnVerifyListener { override fun onSuccess() { _isBusyState.value = false - onSignedIn.call() + onCodeVerified() } override fun onFailed(error: String?) { @@ -227,6 +227,13 @@ class AuthenticationViewModel(application: Application) : ObservableAndroidViewM }) } + fun onCodeVerified() { + val defaultArchiveId = prefsHelper.getDefaultArchiveId() + + if (defaultArchiveId == 0) onUserMissingDefaultArchive.call() + else getArchive(defaultArchiveId) + } + fun updateCodeValues(newValues: List) { _codeValues.value = newValues }