mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-28 20:45:17 +00:00
refactor: let the local number update recipient details in profile manager
This commit is contained in:
parent
e059fdaa19
commit
74f05a166b
@ -50,10 +50,10 @@ class ProfileManager(private val context: Context, private val configFactory: Co
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun setProfilePictureURL(context: Context, recipient: Recipient, profilePictureURL: String) {
|
override fun setProfilePictureURL(context: Context, recipient: Recipient, profilePictureURL: String) {
|
||||||
if (recipient.isLocalNumber) return
|
|
||||||
val job = RetrieveProfileAvatarJob(recipient, profilePictureURL)
|
val job = RetrieveProfileAvatarJob(recipient, profilePictureURL)
|
||||||
val jobManager = ApplicationContext.getInstance(context).jobManager
|
val jobManager = ApplicationContext.getInstance(context).jobManager
|
||||||
jobManager.add(job)
|
jobManager.add(job)
|
||||||
|
if (recipient.isLocalNumber) return
|
||||||
val sessionID = recipient.address.serialize()
|
val sessionID = recipient.address.serialize()
|
||||||
val contactDatabase = DatabaseComponent.get(context).sessionContactDatabase()
|
val contactDatabase = DatabaseComponent.get(context).sessionContactDatabase()
|
||||||
var contact = contactDatabase.getContactWithSessionID(sessionID)
|
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?) {
|
override fun setProfileKey(context: Context, recipient: Recipient, profileKey: ByteArray?) {
|
||||||
if (recipient.isLocalNumber) return
|
|
||||||
// New API
|
// New API
|
||||||
val sessionID = recipient.address.serialize()
|
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()
|
val contactDatabase = DatabaseComponent.get(context).sessionContactDatabase()
|
||||||
var contact = contactDatabase.getContactWithSessionID(sessionID)
|
var contact = contactDatabase.getContactWithSessionID(sessionID)
|
||||||
if (contact == null) contact = Contact(sessionID)
|
if (contact == null) contact = Contact(sessionID)
|
||||||
@ -78,9 +82,6 @@ class ProfileManager(private val context: Context, private val configFactory: Co
|
|||||||
contact.profilePictureEncryptionKey = profileKey
|
contact.profilePictureEncryptionKey = profileKey
|
||||||
contactDatabase.setContact(contact)
|
contactDatabase.setContact(contact)
|
||||||
}
|
}
|
||||||
// Old API
|
|
||||||
val database = DatabaseComponent.get(context).recipientDatabase()
|
|
||||||
database.setProfileKey(recipient, profileKey)
|
|
||||||
contactUpdatedInternal(contact)
|
contactUpdatedInternal(contact)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user