Ensure username is reclaimed after account restore.

This commit is contained in:
Greyson Parrelli 2024-09-16 12:53:36 -04:00
parent dc77226995
commit 2180b78466
2 changed files with 8 additions and 10 deletions

View file

@ -156,7 +156,6 @@ object SvrRepository {
SignalStore.svr.isRegistrationLockEnabled = false SignalStore.svr.isRegistrationLockEnabled = false
SignalStore.pin.resetPinReminders() SignalStore.pin.resetPinReminders()
SignalStore.svr.isPinForgottenOrSkipped = false SignalStore.svr.isPinForgottenOrSkipped = false
SignalStore.storageService.setNeedsAccountRestore(false)
SignalStore.pin.keyboardType = pinKeyboardType SignalStore.pin.keyboardType = pinKeyboardType
SignalStore.storageService.setNeedsAccountRestore(false) SignalStore.storageService.setNeedsAccountRestore(false)

View file

@ -827,26 +827,25 @@ class RegistrationViewModel : ViewModel() {
if (reglockEnabled) { if (reglockEnabled) {
SignalStore.onboarding.clearAll() SignalStore.onboarding.clearAll()
val stopwatch = Stopwatch("RegistrationLockRestore") }
if (reglockEnabled || SignalStore.storageService.lastSyncTime == 0L) {
val stopwatch = Stopwatch("post-reg-storage-service")
AppDependencies.jobManager.runSynchronously(StorageAccountRestoreJob(), StorageAccountRestoreJob.LIFESPAN) AppDependencies.jobManager.runSynchronously(StorageAccountRestoreJob(), StorageAccountRestoreJob.LIFESPAN)
stopwatch.split("AccountRestore") stopwatch.split("account-restore")
AppDependencies.jobManager AppDependencies.jobManager
.startChain(StorageSyncJob()) .startChain(StorageSyncJob())
.then(ReclaimUsernameAndLinkJob()) .then(ReclaimUsernameAndLinkJob())
.enqueueAndBlockUntilCompletion(TimeUnit.SECONDS.toMillis(10)) .enqueueAndBlockUntilCompletion(TimeUnit.SECONDS.toMillis(10))
stopwatch.split("ContactRestore") stopwatch.split("storage-sync")
refreshRemoteConfig()
stopwatch.split("RemoteConfig")
stopwatch.stop(TAG) stopwatch.stop(TAG)
} else {
refreshRemoteConfig()
} }
refreshRemoteConfig()
store.update { store.update {
it.copy( it.copy(
registrationCheckpoint = RegistrationCheckpoint.LOCAL_REGISTRATION_COMPLETE, registrationCheckpoint = RegistrationCheckpoint.LOCAL_REGISTRATION_COMPLETE,