Skip to content

Commit

Permalink
chore: fix issues with profile page (#1598)
Browse files Browse the repository at this point in the history
  • Loading branch information
tcheee authored Dec 27, 2024
1 parent f314871 commit b581896
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 12 deletions.
13 changes: 7 additions & 6 deletions src/components/Leaderboard/Leaderboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { LeaderboardEntrySkeleton } from './LeaderboardEntrySkeleton';
import { LeaderboardUserEntry } from './LeaderboardUserEntry';
import IconHeader from '../ProfilePage/Common/IconHeader';
import useClient from 'src/hooks/useClient';
import { Box } from '@mui/material';

export const LEADERBOARD_LENGTH = 25;

Expand Down Expand Up @@ -78,17 +79,17 @@ export const Leaderboard = ({ page: defaultPage }: { page: number }) => {
<LeaderboardEntryStack direction={'column'}>
{!leaderboardData?.length
? Array.from({ length: LEADERBOARD_LENGTH }).map((_, index) => (
<>
<Box key={`leaderboard-entry-${index}-fragment`}>
<LeaderboardEntrySkeleton
key={`leaderboard-entry-${index}-skeleton`}
isUserPosition={false}
/>
{index !== LEADERBOARD_LENGTH - 1 && (
<LeaderboardEntryDivider
key={`leaderboard-entry-${index}-skeleton-divider`}
key={`leaderboard-entry-divider=${index}-skeleton`}
/>
)}
</>
</Box>
))
: leaderboardData?.map(
(entry: LeaderboardEntryData, index: number) => {
Expand All @@ -97,7 +98,7 @@ export const Leaderboard = ({ page: defaultPage }: { page: number }) => {
+parseInt(leaderboardUserData?.position);

return (
<>
<Box key={`leaderboard-entry-${index}-fragment`}>
<LeaderboardEntry
key={`leaderboard-entry-${index}`}
isUserPosition={isUserPosition}
Expand All @@ -107,10 +108,10 @@ export const Leaderboard = ({ page: defaultPage }: { page: number }) => {
/>
{index !== leaderboardData.length - 1 && (
<LeaderboardEntryDivider
key={`leaderboard-entry-${index}-divider`}
key={`leaderboard-entry-divider-${index}`}
/>
)}
</>
</Box>
);
},
)}
Expand Down
3 changes: 2 additions & 1 deletion src/components/Leaderboard/LeaderboardEntry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {

import { useWalletAddressImg } from 'src/hooks/useAddressImg';
import { obfuscatedAddressFormatter } from 'src/utils/obfuscatedAddressFormatter';
import useBlockieImg from 'src/hooks/useBlockieImg';

interface LeaderboardEntryProps {
isUserPosition?: boolean;
Expand All @@ -35,7 +36,7 @@ export const LeaderboardEntry = ({
}: LeaderboardEntryProps) => {
const { t } = useTranslation();
const formattedAddress = obfuscatedAddressFormatter(walletAddress);
const imgLink = useWalletAddressImg(formattedAddress);
const imgLink = useBlockieImg(formattedAddress);

return (
<LeaderboardEntryWrapper
Expand Down
1 change: 0 additions & 1 deletion src/components/Leaderboard/LeaderboardUserEntry.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
'use client';

import { useAccount } from '@lifi/wallet-management';
import { useLoyaltyPass } from 'src/hooks/useLoyaltyPass';
import { useLeaderboardUser } from '../../hooks/useLeaderboard';
Expand Down
4 changes: 3 additions & 1 deletion src/components/Navbar/WalletButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ export const WalletButtons = () => {
const { openWalletMenu } = useWalletMenu();
const { points, isLoading } = useLoyaltyPass(account?.address);
const router = useRouter();
const imgLink = useWalletAddressImg(account?.address);
const imgLink = useWalletAddressImg({
userAddress: account?.address,
});
const isDesktop = useMediaQuery((theme: Theme) => theme.breakpoints.up('md'));
const pathname = usePathname();

Expand Down
4 changes: 3 additions & 1 deletion src/components/ProfilePage/AddressBox/AddressBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ interface AddressBoxProps {
export const AddressBox = ({ address }: AddressBoxProps) => {
const { t } = useTranslation();
const theme = useTheme();
const imgLink = useWalletAddressImg(address);
const imgLink = useWalletAddressImg({
userAddress: address,
});
const { setSnackbarState } = useMenuStore((state) => state);
const { data: ensName, isSuccess } = useEnsName({
address: address as Address | undefined,
Expand Down
4 changes: 3 additions & 1 deletion src/components/ProfilePage/AddressCard/AddressCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ export const AddressCard = ({ address }: AddressBoxProps) => {
address: address as Address | undefined,
chainId: mainnet.id,
});
const imgLink = useWalletAddressImg(address);
const imgLink = useWalletAddressImg({
userAddress: address,
});
const { setSnackbarState } = useMenuStore((state) => state);
const { openWalletMenu } = useWalletMenu();

Expand Down
8 changes: 7 additions & 1 deletion src/hooks/useAddressImg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ import { mainnet } from 'wagmi/chains';
import { normalize } from 'viem/ens';
import { DEFAULT_WALLET_ADDRESS } from '@/const/urls';

export const useWalletAddressImg = (userAddress?: string) => {
interface UseWalletAddressImgProps {
userAddress?: string;
}

export const useWalletAddressImg = ({
userAddress,
}: UseWalletAddressImgProps) => {
const { imageLink: merkleNFTImg } = useMercleNft({ userAddress });
const { data: ensImage } = useEnsAvatar({
chainId: mainnet.id,
Expand Down
2 changes: 2 additions & 0 deletions src/hooks/useLeaderboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export const useLeaderboardList = (
console.error(err);
}
},
refetchInterval: 1000 * 60 * 60,
});

const data = leaderboardListData?.data;
Expand Down Expand Up @@ -107,6 +108,7 @@ export const useLeaderboardUser = (
} = useQuery({
queryKey: ['leaderboard-user', walletAddress],
queryFn: getLeaderboardUserQuery,
refetchInterval: 1000 * 60 * 60,
});

const userPage =
Expand Down

0 comments on commit b581896

Please sign in to comment.