mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-28 20:45:17 +00:00
fix: maybe fix avatar download for new messages
This commit is contained in:
parent
96969789cc
commit
c741ec5093
@ -184,6 +184,12 @@ open class Storage(context: Context, helper: SQLCipherOpenHelper, private val co
|
||||
database.setProfileAvatar(recipient, profileAvatar)
|
||||
}
|
||||
|
||||
override fun setProfilePicture(recipient: Recipient, newProfilePicture: String?, newProfileKey: ByteArray?) {
|
||||
val db = DatabaseComponent.get(context).recipientDatabase()
|
||||
db.setProfileAvatar(recipient, newProfilePicture)
|
||||
db.setProfileKey(recipient, newProfileKey)
|
||||
}
|
||||
|
||||
override fun setUserProfilePicture(newProfilePicture: String?, newProfileKey: ByteArray?) {
|
||||
val ourRecipient = fromSerialized(getUserPublicKey()!!).let {
|
||||
Recipient.from(context, it, false)
|
||||
|
@ -55,15 +55,18 @@ class ProfileManager(private val context: Context, private val configFactory: Co
|
||||
profilePictureURL: String?,
|
||||
profileKey: ByteArray?
|
||||
) {
|
||||
val job = RetrieveProfileAvatarJob(profilePictureURL, recipient.address)
|
||||
if (DatabaseComponent
|
||||
val hasPendingDownload = DatabaseComponent
|
||||
.get(context)
|
||||
.sessionJobDatabase()
|
||||
.getAllJobs(RetrieveProfileAvatarJob.KEY).none {
|
||||
.getAllJobs(RetrieveProfileAvatarJob.KEY).any {
|
||||
(it.value as? RetrieveProfileAvatarJob)?.recipientAddress == recipient.address
|
||||
}) {
|
||||
JobQueue.shared.add(job)
|
||||
}
|
||||
val resolved = recipient.resolve()
|
||||
DatabaseComponent.get(context).storage().setProfilePicture(
|
||||
recipient = resolved,
|
||||
newProfileKey = profileKey,
|
||||
newProfilePicture = profilePictureURL
|
||||
)
|
||||
val sessionID = recipient.address.serialize()
|
||||
val contactDatabase = DatabaseComponent.get(context).sessionContactDatabase()
|
||||
var contact = contactDatabase.getContactWithSessionID(sessionID)
|
||||
@ -75,6 +78,10 @@ class ProfileManager(private val context: Context, private val configFactory: Co
|
||||
contactDatabase.setContact(contact)
|
||||
}
|
||||
contactUpdatedInternal(contact)
|
||||
if (!hasPendingDownload) {
|
||||
val job = RetrieveProfileAvatarJob(profilePictureURL, recipient.address)
|
||||
JobQueue.shared.add(job)
|
||||
}
|
||||
}
|
||||
|
||||
override fun setUnidentifiedAccessMode(context: Context, recipient: Recipient, unidentifiedAccessMode: Recipient.UnidentifiedAccessMode) {
|
||||
|
@ -41,6 +41,7 @@ interface StorageProtocol {
|
||||
fun getUserX25519KeyPair(): ECKeyPair
|
||||
fun getUserProfile(): Profile
|
||||
fun setProfileAvatar(recipient: Recipient, profileAvatar: String?)
|
||||
fun setProfilePicture(recipient: Recipient, newProfilePicture: String?, newProfileKey: ByteArray?)
|
||||
fun setUserProfilePicture(newProfilePicture: String?, newProfileKey: ByteArray?)
|
||||
fun clearUserPic()
|
||||
// Signal
|
||||
|
Loading…
Reference in New Issue
Block a user