mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-25 02:55:23 +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)
|
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?) {
|
override fun setUserProfilePicture(newProfilePicture: String?, newProfileKey: ByteArray?) {
|
||||||
val ourRecipient = fromSerialized(getUserPublicKey()!!).let {
|
val ourRecipient = fromSerialized(getUserPublicKey()!!).let {
|
||||||
Recipient.from(context, it, false)
|
Recipient.from(context, it, false)
|
||||||
|
@ -55,15 +55,18 @@ class ProfileManager(private val context: Context, private val configFactory: Co
|
|||||||
profilePictureURL: String?,
|
profilePictureURL: String?,
|
||||||
profileKey: ByteArray?
|
profileKey: ByteArray?
|
||||||
) {
|
) {
|
||||||
val job = RetrieveProfileAvatarJob(profilePictureURL, recipient.address)
|
val hasPendingDownload = DatabaseComponent
|
||||||
if (DatabaseComponent
|
.get(context)
|
||||||
.get(context)
|
.sessionJobDatabase()
|
||||||
.sessionJobDatabase()
|
.getAllJobs(RetrieveProfileAvatarJob.KEY).any {
|
||||||
.getAllJobs(RetrieveProfileAvatarJob.KEY).none {
|
(it.value as? RetrieveProfileAvatarJob)?.recipientAddress == recipient.address
|
||||||
(it.value as? RetrieveProfileAvatarJob)?.recipientAddress == recipient.address
|
}
|
||||||
}) {
|
val resolved = recipient.resolve()
|
||||||
JobQueue.shared.add(job)
|
DatabaseComponent.get(context).storage().setProfilePicture(
|
||||||
}
|
recipient = resolved,
|
||||||
|
newProfileKey = profileKey,
|
||||||
|
newProfilePicture = profilePictureURL
|
||||||
|
)
|
||||||
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)
|
||||||
@ -75,6 +78,10 @@ class ProfileManager(private val context: Context, private val configFactory: Co
|
|||||||
contactDatabase.setContact(contact)
|
contactDatabase.setContact(contact)
|
||||||
}
|
}
|
||||||
contactUpdatedInternal(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) {
|
override fun setUnidentifiedAccessMode(context: Context, recipient: Recipient, unidentifiedAccessMode: Recipient.UnidentifiedAccessMode) {
|
||||||
|
@ -41,6 +41,7 @@ interface StorageProtocol {
|
|||||||
fun getUserX25519KeyPair(): ECKeyPair
|
fun getUserX25519KeyPair(): ECKeyPair
|
||||||
fun getUserProfile(): Profile
|
fun getUserProfile(): Profile
|
||||||
fun setProfileAvatar(recipient: Recipient, profileAvatar: String?)
|
fun setProfileAvatar(recipient: Recipient, profileAvatar: String?)
|
||||||
|
fun setProfilePicture(recipient: Recipient, newProfilePicture: String?, newProfileKey: ByteArray?)
|
||||||
fun setUserProfilePicture(newProfilePicture: String?, newProfileKey: ByteArray?)
|
fun setUserProfilePicture(newProfilePicture: String?, newProfileKey: ByteArray?)
|
||||||
fun clearUserPic()
|
fun clearUserPic()
|
||||||
// Signal
|
// Signal
|
||||||
|
Loading…
Reference in New Issue
Block a user