From dba0d180656359a2f7e7fb732374686c4c63074e Mon Sep 17 00:00:00 2001 From: Kgothatso Ngako Date: Sat, 2 May 2026 18:21:47 +0200 Subject: [PATCH] Improve human-readable displayName --- .../compose/database/model/Profile.kt | 35 +++++++++++++++---- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/ac/cord/auxiliary/compose/database/model/Profile.kt b/composeApp/src/commonMain/kotlin/ac/cord/auxiliary/compose/database/model/Profile.kt index 90063794..636f934f 100644 --- a/composeApp/src/commonMain/kotlin/ac/cord/auxiliary/compose/database/model/Profile.kt +++ b/composeApp/src/commonMain/kotlin/ac/cord/auxiliary/compose/database/model/Profile.kt @@ -9,6 +9,7 @@ import ac.cord.auxiliary.compose.database.model.traits.UserViewableEntity import ac.cord.auxiliary.compose.ui.composable.navigation.routes.NostrEventDetailRoute import ac.cord.auxiliary.compose.ui.composable.navigation.routes.Route import ac.cord.auxiliary.compose.ui.composable.widgets.profile.ProfileAvatar +import ac.cord.auxiliary.compose.ui.composable.widgets.profile.ProfileColor import ac.cord.auxiliary.compose.ui.theme.AuxTheme import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement @@ -74,11 +75,29 @@ data class Profile( override val broadcastedAt: Instant? = null, ): NostrEventEntity, TimestampedEntity, LocalStoreEntity, UserViewableEntity, BroadcastableEntity, SoftDeletableEntity { fun humanReadableNameOrPubkey(): String { - return displayName ?: userName ?: lud16 ?: nip05 ?: twitter ?: publicKey + return if (!displayName.isNullOrBlank()) { + displayName + } else if (!userName.isNullOrBlank()) { + userName + } else if (!nip05.isNullOrBlank()) { + nip05 + } else if (!lud16.isNullOrBlank()) { + lud16 + } else if (!twitter.isNullOrBlank()) { + twitter + } else { + publicKey.take(8) + } } fun staticIdentifier(): String? { - return lud16 ?: nip05 + return if (!nip05.isNullOrBlank()) { + nip05 + } else if (!lud16.isNullOrBlank()) { + lud16 + } else { + null + } } @Composable @@ -127,10 +146,14 @@ data class Profile( style = MaterialTheme.typography.bodyMedium ) - Text( - text = nip05 ?: "", - style = MaterialTheme.typography.labelMedium - ) + staticIdentifier()?.let { staticIdentifier -> + Text( + text = staticIdentifier, + style = MaterialTheme.typography.labelMedium, + color = ProfileColor.fromPublicKey(publicKey) + ) + } + } } }