Profile loading hook bug

This commit is contained in:
Kieran 2023-07-05 16:12:27 +01:00
parent ec518f4f6f
commit 4903e142d7
Signed by: Kieran
GPG Key ID: DE71CEB3925BE941

View File

@ -38,7 +38,7 @@ export function Profile({
profile?: UserMetadata profile?: UserMetadata
}) { }) {
const { inView, ref } = useInView(); const { inView, ref } = useInView();
profile ??= useUserProfile(System, inView ? pubkey : undefined); const pLoaded = useUserProfile(System, inView && !profile ? pubkey : undefined) || profile;
const showAvatar = options?.showAvatar ?? true; const showAvatar = options?.showAvatar ?? true;
const showName = options?.showName ?? true; const showName = options?.showName ?? true;
@ -49,16 +49,16 @@ export function Profile({
<Icon size={40} name="zap-filled" /> <Icon size={40} name="zap-filled" />
) : ( ) : (
<img <img
alt={profile?.name || pubkey} alt={pLoaded?.name || pubkey}
className={avatarClassname ? avatarClassname : ""} className={avatarClassname ? avatarClassname : ""}
src={profile?.picture ?? ""} src={pLoaded?.picture ?? ""}
/> />
))} ))}
{showName && ( {showName && (
<span> <span>
{options?.overrideName ?? pubkey === "anon" {options?.overrideName ?? pubkey === "anon"
? "Anon" ? "Anon"
: getName(pubkey, profile)} : getName(pubkey, pLoaded)}
</span> </span>
)} )}
</> </>