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.pin.resetPinReminders()
SignalStore.svr.isPinForgottenOrSkipped = false
SignalStore.storageService.setNeedsAccountRestore(false)
SignalStore.pin.keyboardType = pinKeyboardType
SignalStore.storageService.setNeedsAccountRestore(false)

View file

@ -827,26 +827,25 @@ class RegistrationViewModel : ViewModel() {
if (reglockEnabled) {
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)
stopwatch.split("AccountRestore")
stopwatch.split("account-restore")
AppDependencies.jobManager
.startChain(StorageSyncJob())
.then(ReclaimUsernameAndLinkJob())
.enqueueAndBlockUntilCompletion(TimeUnit.SECONDS.toMillis(10))
stopwatch.split("ContactRestore")
refreshRemoteConfig()
stopwatch.split("RemoteConfig")
stopwatch.split("storage-sync")
stopwatch.stop(TAG)
} else {
refreshRemoteConfig()
}
refreshRemoteConfig()
store.update {
it.copy(
registrationCheckpoint = RegistrationCheckpoint.LOCAL_REGISTRATION_COMPLETE,