From 96dded096f68823b5ade5bc25c5f829ec421da70 Mon Sep 17 00:00:00 2001 From: ThomasSession Date: Tue, 6 Aug 2024 12:24:42 +1000 Subject: [PATCH 1/3] Making sure the username is saved when creating an account --- .../securesms/onboarding/manager/CreateAccountManager.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/onboarding/manager/CreateAccountManager.kt b/app/src/main/java/org/thoughtcrime/securesms/onboarding/manager/CreateAccountManager.kt index 98e9c8b20d..960f53aa22 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/onboarding/manager/CreateAccountManager.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/onboarding/manager/CreateAccountManager.kt @@ -8,6 +8,7 @@ import org.session.libsignal.utilities.KeyHelper import org.session.libsignal.utilities.hexEncodedPublicKey import org.thoughtcrime.securesms.crypto.KeyPairUtilities import org.thoughtcrime.securesms.dependencies.ConfigFactory +import org.thoughtcrime.securesms.util.ConfigurationMessageUtilities import org.thoughtcrime.securesms.util.VersionDataFetcher import javax.inject.Inject import javax.inject.Singleton @@ -24,7 +25,6 @@ class CreateAccountManager @Inject constructor( fun createAccount(displayName: String) { prefs.setProfileName(displayName) - configFactory.user?.setName(displayName) // This is here to resolve a case where the app restarts before a user completes onboarding // which can result in an invalid database state @@ -37,13 +37,16 @@ class CreateAccountManager @Inject constructor( val x25519KeyPair = keyPairGenerationResult.x25519KeyPair KeyPairUtilities.store(application, seed, ed25519KeyPair, x25519KeyPair) - configFactory.keyPairChanged() val userHexEncodedPublicKey = x25519KeyPair.hexEncodedPublicKey val registrationID = KeyHelper.generateRegistrationId(false) prefs.setLocalRegistrationId(registrationID) prefs.setLocalNumber(userHexEncodedPublicKey) prefs.setRestorationTime(0) + configFactory.keyPairChanged() + configFactory.user?.setName(displayName) + ConfigurationMessageUtilities.forceSyncConfigurationNowIfNeeded(application) + versionDataFetcher.startTimedVersionCheck() } } \ No newline at end of file From 514c19e33f34d3cd15f312e9420e2ab4417f2351 Mon Sep 17 00:00:00 2001 From: ThomasSession Date: Tue, 6 Aug 2024 14:58:54 +1000 Subject: [PATCH 2/3] Relying on the home config sync --- .../java/org/thoughtcrime/securesms/home/HomeActivity.kt | 9 +++------ .../securesms/onboarding/manager/CreateAccountManager.kt | 1 - 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/home/HomeActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/home/HomeActivity.kt index 30373f8dbb..b534e6c9d9 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/home/HomeActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/home/HomeActivity.kt @@ -355,12 +355,9 @@ class HomeActivity : PassphraseRequiredActionBarActivity(), updateLegacyConfigView() - // TODO: remove this after enough updates that we can rely on ConfigBase.isNewConfigEnabled to always return true - // This will only run if we aren't using new configs, as they are schedule to sync when there are changes applied - if (textSecurePreferences.getConfigurationMessageSynced()) { - lifecycleScope.launch(Dispatchers.IO) { - ConfigurationMessageUtilities.syncConfigurationIfNeeded(this@HomeActivity) - } + // Sync config changes if there are any + lifecycleScope.launch(Dispatchers.IO) { + ConfigurationMessageUtilities.syncConfigurationIfNeeded(this@HomeActivity) } } diff --git a/app/src/main/java/org/thoughtcrime/securesms/onboarding/manager/CreateAccountManager.kt b/app/src/main/java/org/thoughtcrime/securesms/onboarding/manager/CreateAccountManager.kt index 960f53aa22..cdcbf75a73 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/onboarding/manager/CreateAccountManager.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/onboarding/manager/CreateAccountManager.kt @@ -45,7 +45,6 @@ class CreateAccountManager @Inject constructor( configFactory.keyPairChanged() configFactory.user?.setName(displayName) - ConfigurationMessageUtilities.forceSyncConfigurationNowIfNeeded(application) versionDataFetcher.startTimedVersionCheck() } From 71f9548343756367b388932e2f92bd0030a610ee Mon Sep 17 00:00:00 2001 From: ThomasSession Date: Tue, 6 Aug 2024 14:59:41 +1000 Subject: [PATCH 3/3] comments --- .../securesms/onboarding/manager/CreateAccountManager.kt | 1 + .../securesms/onboarding/pickname/PickDisplayNameViewModel.kt | 1 + 2 files changed, 2 insertions(+) diff --git a/app/src/main/java/org/thoughtcrime/securesms/onboarding/manager/CreateAccountManager.kt b/app/src/main/java/org/thoughtcrime/securesms/onboarding/manager/CreateAccountManager.kt index cdcbf75a73..40bf577255 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/onboarding/manager/CreateAccountManager.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/onboarding/manager/CreateAccountManager.kt @@ -43,6 +43,7 @@ class CreateAccountManager @Inject constructor( prefs.setLocalNumber(userHexEncodedPublicKey) prefs.setRestorationTime(0) + // we'll rely on the config syncing in the homeActivity resume configFactory.keyPairChanged() configFactory.user?.setName(displayName) diff --git a/app/src/main/java/org/thoughtcrime/securesms/onboarding/pickname/PickDisplayNameViewModel.kt b/app/src/main/java/org/thoughtcrime/securesms/onboarding/pickname/PickDisplayNameViewModel.kt index 99b697037d..d17c6f602c 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/onboarding/pickname/PickDisplayNameViewModel.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/onboarding/pickname/PickDisplayNameViewModel.kt @@ -49,6 +49,7 @@ internal class PickDisplayNameViewModel( viewModelScope.launch(Dispatchers.IO) { if (loadFailed) { prefs.setProfileName(displayName) + // we'll rely on the config syncing in the homeActivity resume configFactory.user?.setName(displayName) _events.emit(Event.LoadAccountComplete)