mirror of
https://github.com/oxen-io/session-android.git
synced 2025-08-12 07:57:43 +00:00
minor refactor on storing display names
This commit is contained in:
@@ -93,12 +93,6 @@ class Storage(context: Context, helper: SQLCipherOpenHelper) : Database(context,
|
||||
return database.getDisplayName(recipientPublicKey)
|
||||
}
|
||||
|
||||
override fun setProfileKeyForRecipient(recipientPublicKey: String, profileKey: ByteArray) {
|
||||
val address = Address.fromSerialized(recipientPublicKey)
|
||||
val recipient = Recipient.from(context, address, false)
|
||||
DatabaseFactory.getRecipientDatabase(context).setProfileKey(recipient, profileKey)
|
||||
}
|
||||
|
||||
override fun getOrGenerateRegistrationID(): Int {
|
||||
var registrationID = TextSecurePreferences.getLocalRegistrationId(context)
|
||||
if (registrationID == 0) {
|
||||
@@ -529,14 +523,6 @@ class Storage(context: Context, helper: SQLCipherOpenHelper) : Database(context,
|
||||
return DatabaseFactory.getLokiUserDatabase(context).getDisplayName(publicKey)
|
||||
}
|
||||
|
||||
override fun setDisplayName(publicKey: String, newName: String) {
|
||||
DatabaseFactory.getLokiUserDatabase(context).setDisplayName(publicKey, newName)
|
||||
}
|
||||
|
||||
override fun getServerDisplayName(serverID: String, publicKey: String): String? {
|
||||
return DatabaseFactory.getLokiUserDatabase(context).getServerDisplayName(serverID, publicKey)
|
||||
}
|
||||
|
||||
override fun getProfilePictureURL(publicKey: String): String? {
|
||||
return DatabaseFactory.getLokiUserDatabase(context).getProfilePictureURL(publicKey)
|
||||
}
|
||||
|
@@ -5,12 +5,22 @@ import org.session.libsession.messaging.threads.recipients.Recipient
|
||||
import org.session.libsession.utilities.SSKEnvironment
|
||||
import org.thoughtcrime.securesms.ApplicationContext
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase
|
||||
import org.thoughtcrime.securesms.jobs.RetrieveProfileAvatarJob
|
||||
|
||||
class ProfileManager: SSKEnvironment.ProfileManagerProtocol {
|
||||
override fun setDisplayName(context: Context, recipient: Recipient, displayName: String) {
|
||||
DatabaseFactory.getLokiUserDatabase(context).setDisplayName(recipient.address.serialize(), displayName)
|
||||
val database = DatabaseFactory.getLokiUserDatabase(context)
|
||||
val publicKey = recipient.address.serialize()
|
||||
if (recipient.profileName == null) {
|
||||
// Migrate the profile name in LokiUserDatabase to recipient
|
||||
database.getDisplayName(publicKey)?.let { setProfileName(context, recipient, it) }
|
||||
}
|
||||
database.setDisplayName(publicKey, displayName)
|
||||
}
|
||||
|
||||
override fun setProfileName(context: Context, recipient: Recipient, profileName: String) {
|
||||
val database = DatabaseFactory.getRecipientDatabase(context)
|
||||
database.setProfileName(recipient, profileName)
|
||||
}
|
||||
|
||||
override fun setProfilePictureURL(context: Context, recipient: Recipient, profilePictureURL: String) {
|
||||
|
Reference in New Issue
Block a user