Simplify AvatarData and avoid carrying ByteArray

This commit is contained in:
ganfra 2023-02-01 15:57:00 +01:00
parent d43d433d38
commit b8860a6658
17 changed files with 99 additions and 115 deletions

View file

@ -41,7 +41,7 @@ fun Avatar(avatarData: AvatarData, modifier: Modifier = Modifier) {
val commonModifier = modifier
.size(avatarData.size.dp)
.clip(CircleShape)
if (avatarData.model == null) {
if (avatarData.url == null) {
InitialsAvatar(
avatarData = avatarData,
modifier = commonModifier,
@ -60,7 +60,7 @@ private fun ImageAvatar(
modifier: Modifier = Modifier,
) {
AsyncImage(
model = avatarData.model,
model = avatarData,
onError = {
Timber.e("TAG", "Error $it\n${it.result}", it.result.throwable)
},

View file

@ -21,29 +21,6 @@ import androidx.compose.runtime.Immutable
@Immutable
data class AvatarData(
val name: String = "",
val model: ByteArray? = null,
val url: String? = null,
val size: AvatarSize = AvatarSize.MEDIUM
) {
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
other as AvatarData
if (name != other.name) return false
if (model != null) {
if (other.model == null) return false
if (!model.contentEquals(other.model)) return false
} else if (other.model != null) return false
if (size != other.size) return false
return true
}
override fun hashCode(): Int {
var result = name.hashCode()
result = 31 * result + (model?.contentHashCode() ?: 0)
result = 31 * result + size.value
return result
}
}
)