From 74f05a166b800b416a217f4b694b11462c7b917e Mon Sep 17 00:00:00 2001 From: 0x330a <92654767+0x330a@users.noreply.github.com> Date: Thu, 6 Apr 2023 11:26:15 +1000 Subject: [PATCH] refactor: let the local number update recipient details in profile manager --- .../securesms/sskenvironment/ProfileManager.kt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/sskenvironment/ProfileManager.kt b/app/src/main/java/org/thoughtcrime/securesms/sskenvironment/ProfileManager.kt index 3bf232d451..eec6038ca8 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/sskenvironment/ProfileManager.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/sskenvironment/ProfileManager.kt @@ -50,10 +50,10 @@ class ProfileManager(private val context: Context, private val configFactory: Co } override fun setProfilePictureURL(context: Context, recipient: Recipient, profilePictureURL: String) { - if (recipient.isLocalNumber) return val job = RetrieveProfileAvatarJob(recipient, profilePictureURL) val jobManager = ApplicationContext.getInstance(context).jobManager jobManager.add(job) + if (recipient.isLocalNumber) return val sessionID = recipient.address.serialize() val contactDatabase = DatabaseComponent.get(context).sessionContactDatabase() var contact = contactDatabase.getContactWithSessionID(sessionID) @@ -67,9 +67,13 @@ class ProfileManager(private val context: Context, private val configFactory: Co } override fun setProfileKey(context: Context, recipient: Recipient, profileKey: ByteArray?) { - if (recipient.isLocalNumber) return // New API val sessionID = recipient.address.serialize() + // Old API + val database = DatabaseComponent.get(context).recipientDatabase() + database.setProfileKey(recipient, profileKey) + if (recipient.isLocalNumber) return + val contactDatabase = DatabaseComponent.get(context).sessionContactDatabase() var contact = contactDatabase.getContactWithSessionID(sessionID) if (contact == null) contact = Contact(sessionID) @@ -78,9 +82,6 @@ class ProfileManager(private val context: Context, private val configFactory: Co contact.profilePictureEncryptionKey = profileKey contactDatabase.setContact(contact) } - // Old API - val database = DatabaseComponent.get(context).recipientDatabase() - database.setProfileKey(recipient, profileKey) contactUpdatedInternal(contact) }