mirror of
https://github.com/oxen-io/session-android.git
synced 2025-08-11 17:27:42 +00:00
Making sure the avatars refresh when changed by other users
This commit is contained in:
@@ -131,8 +131,10 @@ class ProfilePictureView @JvmOverloads constructor(
|
||||
this.recipient = Recipient.from(context, Address.fromSerialized(publicKey), false)
|
||||
this.recipient!!
|
||||
}
|
||||
|
||||
if (profilePicturesCache[imageView] == recipient) return
|
||||
profilePicturesCache[imageView] = recipient
|
||||
// recipient is mutable so without cloning it the line above always returns true as the changes to the underlying recipient happens on both shared instances
|
||||
profilePicturesCache[imageView] = recipient.clone()
|
||||
val signalProfilePicture = recipient.contactPhoto
|
||||
val avatar = (signalProfilePicture as? ProfileContactPhoto)?.avatarObject
|
||||
|
||||
|
@@ -191,11 +191,6 @@ open class Storage(
|
||||
return Profile(displayName, profileKey, profilePictureUrl)
|
||||
}
|
||||
|
||||
override fun setProfileAvatar(recipient: Recipient, profileAvatar: String?) {
|
||||
val database = DatabaseComponent.get(context).recipientDatabase()
|
||||
database.setProfileAvatar(recipient, profileAvatar)
|
||||
}
|
||||
|
||||
override fun setProfilePicture(recipient: Recipient, newProfilePicture: String?, newProfileKey: ByteArray?) {
|
||||
val db = DatabaseComponent.get(context).recipientDatabase()
|
||||
db.setProfileAvatar(recipient, newProfilePicture)
|
||||
@@ -216,7 +211,7 @@ open class Storage(
|
||||
TextSecurePreferences.setProfilePictureURL(context, newProfilePicture)
|
||||
|
||||
if (newProfileKey != null) {
|
||||
JobQueue.shared.add(RetrieveProfileAvatarJob(newProfilePicture, ourRecipient.address))
|
||||
JobQueue.shared.add(RetrieveProfileAvatarJob(newProfilePicture, ourRecipient.address, newProfileKey))
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -61,12 +61,9 @@ class ProfileManager(private val context: Context, private val configFactory: Co
|
||||
.getAllJobs(RetrieveProfileAvatarJob.KEY).any {
|
||||
(it.value as? RetrieveProfileAvatarJob)?.recipientAddress == recipient.address
|
||||
}
|
||||
val resolved = recipient.resolve()
|
||||
DatabaseComponent.get(context).storage().setProfilePicture(
|
||||
recipient = resolved,
|
||||
newProfileKey = profileKey,
|
||||
newProfilePicture = profilePictureURL
|
||||
)
|
||||
|
||||
recipient.resolve()
|
||||
|
||||
val accountID = recipient.address.serialize()
|
||||
val contactDatabase = DatabaseComponent.get(context).sessionContactDatabase()
|
||||
var contact = contactDatabase.getContactWithAccountID(accountID)
|
||||
@@ -79,7 +76,7 @@ class ProfileManager(private val context: Context, private val configFactory: Co
|
||||
}
|
||||
contactUpdatedInternal(contact)
|
||||
if (!hasPendingDownload) {
|
||||
val job = RetrieveProfileAvatarJob(profilePictureURL, recipient.address)
|
||||
val job = RetrieveProfileAvatarJob(profilePictureURL, recipient.address, profileKey)
|
||||
JobQueue.shared.add(job)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user