Skip to content

Commit

Permalink
Update UI for username data
Browse files Browse the repository at this point in the history
  • Loading branch information
teodorus-nathaniel committed Jun 28, 2024
1 parent d333a5e commit 0da28a8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/components/ProfilePreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const ProfilePreview = ({
const {
telegramUsername,
isLoading: loadingTgLink,
isAdmin,
shouldSeeUsername,
} = useTgLink(address, asLink)

// const isMyAddressPart = myAddress === address ? ' my' : ''
Expand Down Expand Up @@ -115,7 +115,7 @@ const ProfilePreview = ({
/>
{onEditClick && !isLoading && editButton}
</div>
{isAdmin &&
{shouldSeeUsername &&
(loadingTgLink ? (
<Skeleton className='w-32' />
) : (
Expand Down
10 changes: 5 additions & 5 deletions src/hooks/useTgLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ import useIsModerationAdmin from './useIsModerationAdmin'

export default function useTgLink(address: string, asLink?: boolean) {
const isAdmin = useIsModerationAdmin()
const shouldRedirect = !!(asLink && isAdmin)
const shouldSeeUsername = !!(asLink && isAdmin)
const { data: linkedIdentity, isLoading } =
getLinkedIdentityFromMainAddressQuery.useQuery(address, {
enabled: shouldRedirect,
enabled: shouldSeeUsername,
})

const telegramProvider = linkedIdentity?.externalProviders.find(
(p) => p.provider === IdentityProvider.Telegram
)
const telegramLink = shouldRedirect
const telegramLink = shouldSeeUsername
? getUserTelegramLink(linkedIdentity)
: undefined

return {
telegramLink,
telegramUsername: telegramProvider?.username,
isLoading: shouldRedirect && isLoading,
isAdmin,
isLoading: shouldSeeUsername && isLoading,
shouldSeeUsername,
}
}

0 comments on commit 0da28a8

Please sign in to comment.