fix(ui): show display names instead of npubs in feed

toNoteDisplayData() now reads User.toBestDisplayName() from cache
instead of always showing npub. Falls back to npub if no metadata.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
nrobi144
2026-03-20 06:48:28 +02:00
parent e80473a7d9
commit e834dbd1e5
@@ -31,19 +31,22 @@ import com.vitorpamplona.quartz.nip19Bech32.toNpub
* Extension to convert Event to NoteDisplayData for the shared NoteCard. * Extension to convert Event to NoteDisplayData for the shared NoteCard.
*/ */
fun Event.toNoteDisplayData(cache: ICacheProvider? = null): NoteDisplayData { fun Event.toNoteDisplayData(cache: ICacheProvider? = null): NoteDisplayData {
val npub = val user = (cache?.getUserIfExists(pubKey) as? User)
try {
pubKey.hexToByteArrayOrNull()?.toNpub() ?: pubKey.take(16) + "..."
} catch (e: Exception) {
pubKey.take(16) + "..."
}
val pictureUrl = (cache?.getUserIfExists(pubKey) as? User)?.profilePicture() val displayName =
user?.toBestDisplayName()
?: try {
pubKey.hexToByteArrayOrNull()?.toNpub() ?: pubKey.take(16) + "..."
} catch (e: Exception) {
pubKey.take(16) + "..."
}
val pictureUrl = user?.profilePicture()
return NoteDisplayData( return NoteDisplayData(
id = id, id = id,
pubKeyHex = pubKey, pubKeyHex = pubKey,
pubKeyDisplay = npub, pubKeyDisplay = displayName,
profilePictureUrl = pictureUrl, profilePictureUrl = pictureUrl,
content = content, content = content,
createdAt = createdAt, createdAt = createdAt,