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:
+11
-8
@@ -31,19 +31,22 @@ import com.vitorpamplona.quartz.nip19Bech32.toNpub
|
||||
* Extension to convert Event to NoteDisplayData for the shared NoteCard.
|
||||
*/
|
||||
fun Event.toNoteDisplayData(cache: ICacheProvider? = null): NoteDisplayData {
|
||||
val npub =
|
||||
try {
|
||||
pubKey.hexToByteArrayOrNull()?.toNpub() ?: pubKey.take(16) + "..."
|
||||
} catch (e: Exception) {
|
||||
pubKey.take(16) + "..."
|
||||
}
|
||||
val user = (cache?.getUserIfExists(pubKey) as? User)
|
||||
|
||||
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(
|
||||
id = id,
|
||||
pubKeyHex = pubKey,
|
||||
pubKeyDisplay = npub,
|
||||
pubKeyDisplay = displayName,
|
||||
profilePictureUrl = pictureUrl,
|
||||
content = content,
|
||||
createdAt = createdAt,
|
||||
|
||||
Reference in New Issue
Block a user