Skip to content

Commit

Permalink
fix: username and use profile hook variables (#1349)
Browse files Browse the repository at this point in the history
  • Loading branch information
andyesp authored Oct 19, 2023
1 parent 08ae971 commit 3e9177b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions src/components/Common/Username.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ function getBlockieScale(size?: string) {
}

const Username = ({ address, size, linked, variant = UsernameVariant.Full, strong = false, className }: Props) => {
const { profile, hasDclProfile } = useProfile(address)
const profileHasName = hasDclProfile && profile!.name && profile!.name.length > 0
const { profile, hasDclProfile, displayableAddress, profileHasName } = useProfile(address)
const blockieScale = getBlockieScale(size)
const isAddressVariant = variant === UsernameVariant.Address
const isAvatarVariant = variant === UsernameVariant.Avatar
Expand All @@ -63,7 +62,7 @@ const Username = ({ address, size, linked, variant = UsernameVariant.Full, stron
<>
{isAddressVariant && (
<>
{profileHasName && profile!.name}
{profileHasName && displayableAddress}
{!profileHasName && <Address value={checksumAddress} className={className} strong={strong} />}
</>
)}
Expand All @@ -73,7 +72,7 @@ const Username = ({ address, size, linked, variant = UsernameVariant.Full, stron
{hasDclProfile && (
<>
<Avatar size={size} address={address} />
{profileHasName && !isAvatarVariant && <span className="Username__Name">{profile!.name}</span>}
{profileHasName && !isAvatarVariant && <span className="Username__Name">{displayableAddress}</span>}
{!profileHasName && !isAvatarVariant && <Address value={checksumAddress} strong={strong} />}
</>
)}
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ export default function useProfile(address?: string | null) {
const profileHasName = hasDclProfile && !!profile.name && profile.name.length > 0 && profile.hasClaimedName
const displayableAddress = profileHasName ? profile.name : address

return { profile, hasDclProfile, displayableAddress, isLoadingProfile }
return { profile, hasDclProfile, displayableAddress, isLoadingProfile, profileHasName }
}

0 comments on commit 3e9177b

Please sign in to comment.