Skip to content

Commit

Permalink
Merge pull request #1600 from oxen-io/fix/username-saved
Browse files Browse the repository at this point in the history
Making sure the username is saved when creating an account
  • Loading branch information
ThomasSession authored Aug 6, 2024
2 parents 0616e14 + 71f9548 commit b6c58f4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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)

// we'll rely on the config syncing in the homeActivity resume
configFactory.keyPairChanged()
configFactory.user?.setName(displayName)

versionDataFetcher.startTimedVersionCheck()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b6c58f4

Please sign in to comment.