Placeholder avatar is incosistent across components #39
@ -42,12 +42,12 @@ export const AppBar = () => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (metadataState && metadataState.content) {
|
if (metadataState && metadataState.content) {
|
||||||
const { picture, display_name, name } = JSON.parse(metadataState.content)
|
const { picture, display_name, name } = JSON.parse(metadataState.content)
|
||||||
const npub = authState?.usersPubkey ? hexToNpub(authState.usersPubkey) : ''
|
const pubkey = authState?.usersPubkey || ''
|
||||||
|
|
||||||
if (picture) {
|
if (picture) {
|
||||||
setUserAvatar(picture)
|
setUserAvatar(picture)
|
||||||
} else {
|
} else {
|
||||||
setUserAvatar(getRoboHashPicture(npub))
|
setUserAvatar(getRoboHashPicture(pubkey))
|
||||||
}
|
}
|
||||||
|
|
||||||
setUsername(shorten(display_name || name || '', 7))
|
setUsername(shorten(display_name || name || '', 7))
|
||||||
|
@ -490,8 +490,7 @@ const DisplayUser = ({
|
|||||||
}, [users])
|
}, [users])
|
||||||
|
|
||||||
const imageLoadError = (event: any, pubkey: string) => {
|
const imageLoadError = (event: any, pubkey: string) => {
|
||||||
const npub = hexToNpub(pubkey)
|
event.target.src = getRoboHashPicture(pubkey)
|
||||||
event.target.src = getRoboHashPicture(npub)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -632,8 +632,7 @@ const DisplayMeta = ({ meta, nextSigner }: DisplayMetaProps) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const getRoboImageUrl = (pubkey: string) => {
|
const getRoboImageUrl = (pubkey: string) => {
|
||||||
const npub = hexToNpub(pubkey)
|
return getRoboHashPicture(pubkey)
|
||||||
return getRoboHashPicture(npub)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -719,8 +718,7 @@ const DisplayMeta = ({ meta, nextSigner }: DisplayMetaProps) => {
|
|||||||
<TableBody>
|
<TableBody>
|
||||||
{users.map((user, index) => {
|
{users.map((user, index) => {
|
||||||
const userMeta = metadata[user.pubkey]
|
const userMeta = metadata[user.pubkey]
|
||||||
const npub = hexToNpub(user.pubkey)
|
const roboUrl = getRoboHashPicture(user.pubkey)
|
||||||
const roboUrl = getRoboHashPicture(npub)
|
|
||||||
|
|
||||||
let signedStatus = '-'
|
let signedStatus = '-'
|
||||||
|
|
||||||
|
@ -140,6 +140,12 @@ export const base64DecodeAuthToken = (authToken: string): SignedEvent => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getRoboHashPicture = (npub: string): string => {
|
/**
|
||||||
|
*
|
||||||
|
* @param pubkey in hex or npub format
|
||||||
|
* @returns robohash.org url for the avatar
|
||||||
|
*/
|
||||||
|
export const getRoboHashPicture = (pubkey: string): string => {
|
||||||
|
const npub = hexToNpub(pubkey)
|
||||||
return `https://robohash.org/${npub}.png?set=set3`
|
return `https://robohash.org/${npub}.png?set=set3`
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user