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.
|
* 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,
|
||||||
|
|||||||
Reference in New Issue
Block a user