Fix display name

This commit is contained in:
Kieran 2023-06-22 15:30:49 +01:00
parent 6a0ee5362a
commit 88497ad00a
Signed by: Kieran
GPG Key ID: DE71CEB3925BE941

View File

@ -13,7 +13,13 @@ export interface ProfileOptions {
export function getName(pk: string, user?: UserMetadata) {
const shortPubkey = hexToBech32("npub", pk).slice(0, 12);
return user?.display_name ?? user?.name ?? shortPubkey
if ((user?.display_name?.length ?? 0) > 0) {
return user?.display_name;
}
if ((user?.name?.length ?? 0) > 0) {
return user?.name;
}
return shortPubkey;
}
export function Profile({ pubkey, options }: { pubkey: string, options?: ProfileOptions }) {