Reduce profile avatar disk reads.

This commit is contained in:
Cody Henthorne
2022-07-13 14:48:25 -04:00
parent 2f17963b2b
commit 819f7a170f
16 changed files with 81 additions and 59 deletions

View File

@@ -3609,7 +3609,7 @@ open class RecipientDatabase(context: Context, databaseHelper: SignalDatabase) :
systemContactUri = cursor.requireString(SYSTEM_CONTACT_URI),
signalProfileName = ProfileName.fromParts(cursor.requireString(PROFILE_GIVEN_NAME), cursor.requireString(PROFILE_FAMILY_NAME)),
signalProfileAvatar = cursor.requireString(SIGNAL_PROFILE_AVATAR),
hasProfileImage = AvatarHelper.hasAvatar(context, recipientId),
profileAvatarFileDetails = AvatarHelper.getAvatarFileDetails(context, recipientId),
profileSharing = cursor.requireBoolean(PROFILE_SHARING),
lastProfileFetch = cursor.requireLong(LAST_PROFILE_FETCH),
notificationChannel = cursor.requireString(NOTIFICATION_CHANNEL),

View File

@@ -0,0 +1,23 @@
package org.thoughtcrime.securesms.database.model
/**
* Details related to the current avatar profile image file that would be returned via [org.thoughtcrime.securesms.profiles.AvatarHelper.getAvatarFile]
* at the time this [org.thoughtcrime.securesms.recipients.Recipient] was loaded/refreshed from the database.
*/
data class ProfileAvatarFileDetails(
val hashId: Long,
val lastModified: Long
) {
fun getDiskCacheKeyBytes(): ByteArray {
return toString().toByteArray()
}
fun hasFile(): Boolean {
return this != NO_DETAILS
}
companion object {
@JvmField
val NO_DETAILS = ProfileAvatarFileDetails(0, 0)
}
}

View File

@@ -55,8 +55,7 @@ data class RecipientRecord(
val signalProfileName: ProfileName,
@get:JvmName("getProfileAvatar")
val signalProfileAvatar: String?,
@get:JvmName("hasProfileImage")
val hasProfileImage: Boolean,
val profileAvatarFileDetails: ProfileAvatarFileDetails,
@get:JvmName("isProfileSharing")
val profileSharing: Boolean,
val lastProfileFetch: Long,