Skip to content

Commit 2180b78

Browse files
Ensure username is reclaimed after account restore.
1 parent dc77226 commit 2180b78

2 files changed

Lines changed: 8 additions & 10 deletions

File tree

app/src/main/java/org/thoughtcrime/securesms/pin/SvrRepository.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ object SvrRepository {
156156
SignalStore.svr.isRegistrationLockEnabled = false
157157
SignalStore.pin.resetPinReminders()
158158
SignalStore.svr.isPinForgottenOrSkipped = false
159-
SignalStore.storageService.setNeedsAccountRestore(false)
160159
SignalStore.pin.keyboardType = pinKeyboardType
161160
SignalStore.storageService.setNeedsAccountRestore(false)
162161

app/src/main/java/org/thoughtcrime/securesms/registration/ui/RegistrationViewModel.kt

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -827,26 +827,25 @@ class RegistrationViewModel : ViewModel() {
827827

828828
if (reglockEnabled) {
829829
SignalStore.onboarding.clearAll()
830-
val stopwatch = Stopwatch("RegistrationLockRestore")
830+
}
831+
832+
if (reglockEnabled || SignalStore.storageService.lastSyncTime == 0L) {
833+
val stopwatch = Stopwatch("post-reg-storage-service")
831834

832835
AppDependencies.jobManager.runSynchronously(StorageAccountRestoreJob(), StorageAccountRestoreJob.LIFESPAN)
833-
stopwatch.split("AccountRestore")
836+
stopwatch.split("account-restore")
834837

835838
AppDependencies.jobManager
836839
.startChain(StorageSyncJob())
837840
.then(ReclaimUsernameAndLinkJob())
838841
.enqueueAndBlockUntilCompletion(TimeUnit.SECONDS.toMillis(10))
839-
stopwatch.split("ContactRestore")
840-
841-
refreshRemoteConfig()
842-
843-
stopwatch.split("RemoteConfig")
842+
stopwatch.split("storage-sync")
844843

845844
stopwatch.stop(TAG)
846-
} else {
847-
refreshRemoteConfig()
848845
}
849846

847+
refreshRemoteConfig()
848+
850849
store.update {
851850
it.copy(
852851
registrationCheckpoint = RegistrationCheckpoint.LOCAL_REGISTRATION_COMPLETE,

0 commit comments

Comments
 (0)