From ef73039d94841fe8268c3545ebfac8829c327684 Mon Sep 17 00:00:00 2001 From: teodorus-nathaniel Date: Sun, 21 Jan 2024 19:55:07 +0700 Subject: [PATCH 1/4] feat: fetch top users profiles from client side if server side fails --- src/components/creators/TopUsersCard.tsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/components/creators/TopUsersCard.tsx b/src/components/creators/TopUsersCard.tsx index d78b8f39b..a890e993a 100644 --- a/src/components/creators/TopUsersCard.tsx +++ b/src/components/creators/TopUsersCard.tsx @@ -1,7 +1,7 @@ import { Skeleton } from 'antd' import clsx from 'clsx' -import { ComponentProps, CSSProperties } from 'react' -import { useSelectProfileSpace, useSelectSpace } from 'src/rtk/app/hooks' +import { ComponentProps, CSSProperties, useMemo } from 'react' +import { useFetchProfileSpaces, useSelectProfileSpace, useSelectSpace } from 'src/rtk/app/hooks' import { useFetchTopUsers } from 'src/rtk/features/activeStaking/hooks' import { useIsMobileWidthOrDevice } from '../responsive' import { SpaceAvatar } from '../spaces/helpers' @@ -15,7 +15,15 @@ export default function TopUsersCard({ ...props }: TopUsersCardProps) { const { data, loading } = useFetchTopUsers() const isMobile = useIsMobileWidthOrDevice() - const isLoading = loading || !data + const args = useMemo( + () => ({ + ids: [...(data?.stakers ?? []), ...(data?.creators ?? [])].map(({ address }) => address), + }), + [data], + ) + const { loading: loadingSpaces } = useFetchProfileSpaces(args) + + const isLoading = loading || !data || loadingSpaces // const seeMoreButton = ( //