diff --git a/app/src/main/java/org/thoughtcrime/securesms/registration/ui/RegistrationViewModel.kt b/app/src/main/java/org/thoughtcrime/securesms/registration/ui/RegistrationViewModel.kt index c5d9230541..cc23ee78ab 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/registration/ui/RegistrationViewModel.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/registration/ui/RegistrationViewModel.kt @@ -248,6 +248,18 @@ class RegistrationViewModel : ViewModel() { } } + fun clearPreviousRegistrationState() { + store.update { + it.copy( + sessionId = null, + captchaToken = null, + challengesRequested = emptyList(), + challengeInProgress = false, + fcmToken = null + ) + } + } + fun onBackupSuccessfullyRestored() { val recoveryPassword = SignalStore.svr.recoveryPassword store.update { diff --git a/app/src/main/java/org/thoughtcrime/securesms/registration/ui/restore/SelectManualRestoreMethodFragment.kt b/app/src/main/java/org/thoughtcrime/securesms/registration/ui/restore/SelectManualRestoreMethodFragment.kt index ba9e1a547d..38f329b949 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/registration/ui/restore/SelectManualRestoreMethodFragment.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/registration/ui/restore/SelectManualRestoreMethodFragment.kt @@ -81,6 +81,7 @@ class SelectManualRestoreMethodFragment : ComposeFragment() { private fun startRestoreMethod(method: RestoreMethod) { when (method) { RestoreMethod.FROM_SIGNAL_BACKUPS -> { + sharedViewModel.clearPreviousRegistrationState() sharedViewModel.intendToRestore(hasOldDevice = false, fromRemote = true) findNavController().safeNavigate(SelectManualRestoreMethodFragmentDirections.goToEnterPhoneNumber(EnterPhoneNumberMode.COLLECT_FOR_MANUAL_SIGNAL_BACKUPS_RESTORE)) }