Skip to content

Commit

Permalink
fix: fix issues in nft
Browse files Browse the repository at this point in the history
  • Loading branch information
jinoosss committed Nov 6, 2024
1 parent a2f7325 commit 31bfd86
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const NFTCollectionAssetsWrapper = styled.div`
.description {
position: absolute;
top: 210px;
top: 139px;
left: 0px;
width: 100%;
text-align: center;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ const NFTCollectionCard: React.FC<NFTCollectionCardProps> = ({
},
);

const { data: balance } = queryGRC721Balance(grc721Collection.packagePath);
const { data: balance } = queryGRC721Balance(grc721Collection.packagePath, {
refetchOnMount: true,
});

const isFetchedCardTokenUri = useMemo(() => {
if (!grc721Collection.isTokenUri) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const NFTCollectionsWrapper = styled.div`
.description {
position: absolute;
top: 210px;
top: 139px;
left: 0px;
width: 100%;
text-align: center;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import styled from 'styled-components';

import { HISTORY_FETCH_INTERVAL_TIME } from '@common/constants/interval.constant';
import { TransactionHistory } from '@components/molecules';
import { useGetAllGRC721Collections } from '@hooks/nft/use-get-all-grc721-collections';
import { useGetGRC721TokenUri } from '@hooks/nft/use-get-grc721-token-uri';
import useAppNavigate from '@hooks/use-app-navigate';
import { useCurrentAccount } from '@hooks/use-current-account';
import { useNetwork } from '@hooks/use-network';
import useScrollHistory from '@hooks/use-scroll-history';
import { useTransactionHistory } from '@hooks/wallet/transaction-history/use-transaction-history';
import { useTransactionHistoryPage } from '@hooks/wallet/transaction-history/use-transaction-history-page';
import { TransactionHistoryMapper } from '@repositories/transaction/mapper/transaction-history-mapper';
import mixins from '@styles/mixins';
import { fonts } from '@styles/theme';
import { RoutePath } from '@types';
Expand Down Expand Up @@ -40,6 +40,8 @@ const HistoryContainer: React.FC = () => {
const { saveScrollPosition } = useScrollHistory(scrollRef);
const { currentNetwork } = useNetwork();

useGetAllGRC721Collections({ refetchOnMount: true });

const isUsedApi = useMemo(() => {
return !!currentNetwork.apiUrl;
}, [currentNetwork]);
Expand All @@ -64,7 +66,7 @@ const HistoryContainer: React.FC = () => {
}, [loadingNextFetch, isLoading, isFetching, hasNextPage]);

useEffect(() => {
if (document.getElementsByTagName('body').length > 0) {
if (document.getElementsByTagName('body') && document.getElementsByTagName('body').length > 0) {
setBodyElement(document.getElementsByTagName('body')[0]);
}
}, [document.getElementsByTagName('body')]);
Expand All @@ -90,10 +92,7 @@ const HistoryContainer: React.FC = () => {

const onClickItem = useCallback(
(hash: string) => {
const transactions =
TransactionHistoryMapper.queryToDisplay(data || []).flatMap(
(group) => group.transactions,
) ?? [];
const transactions = data?.flatMap((group) => group.transactions) ?? [];
const transactionInfo = transactions.find((transaction) => transaction.hash === hash);
if (transactionInfo) {
saveScrollPosition(scrollRef.current?.scrollTop || 0);
Expand All @@ -112,7 +111,7 @@ const HistoryContainer: React.FC = () => {
</StyledTitleWrapper>
<TransactionHistory
status={isSupported ? status : 'error'}
transactionInfoLists={data ? TransactionHistoryMapper.queryToDisplay(data) : []}
transactionInfoLists={data || []}
queryGRC721TokenUri={useGetGRC721TokenUri}
onClickItem={onClickItem}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { DoubleButton, TransactionHistory } from '@components/molecules';
import { useCurrentAccount } from '@hooks/use-current-account';
import useHistoryData from '@hooks/use-history-data';
import useScrollHistory from '@hooks/use-scroll-history';
import { TransactionHistoryMapper } from '@repositories/transaction/mapper/transaction-history-mapper';
import { getTheme } from '@styles/theme';
import { RoutePath } from '@types';

Expand Down Expand Up @@ -143,7 +142,10 @@ export const TokenDetails = (): JSX.Element => {
}, [currentBalances, tokenBalance]);

const transactions = useMemo(() => {
return TransactionHistoryMapper.queryToDisplay(data || []);
if (!data) {
return [];
}
return data;
}, [data]);

const onScrollListener = (): void => {
Expand All @@ -158,10 +160,7 @@ export const TokenDetails = (): JSX.Element => {

const onClickItem = useCallback(
(hash: string) => {
const transactions =
TransactionHistoryMapper.queryToDisplay(data ?? []).flatMap(
(group) => group.transactions,
) ?? [];
const transactions = data?.flatMap((group) => group.transactions) ?? [];
const transactionInfo = transactions.find((transaction) => transaction.hash === hash);
if (transactionInfo) {
saveScrollPosition(scrollRef.current?.scrollTop || 0);
Expand Down

0 comments on commit 31bfd86

Please sign in to comment.