mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 09:49:30 +01:00
Reduce profile avatar disk reads.
This commit is contained in:
@@ -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),
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user