diff --git a/src/pages/Home/index.tsx b/src/pages/Home/index.tsx index 938c83d2d..c7f250a48 100644 --- a/src/pages/Home/index.tsx +++ b/src/pages/Home/index.tsx @@ -14,7 +14,7 @@ import { } from './styled' import Content from '../../components/Content' import { parseTime, parseTimeNoSecond } from '../../utils/date' -import { BLOCK_POLLING_TIME, ListPageParams, DELAY_BLOCK_NUMBER } from '../../constants/common' +import { BLOCK_POLLING_TIME, ListPageParams, DELAY_BLOCK_NUMBER, EPOCHS_PER_HALVING } from '../../constants/common' import { localeNumberString, handleHashRate, handleDifficulty } from '../../utils/number' import { handleBigNumber } from '../../utils/string' import { isMainnet } from '../../utils/chain' @@ -22,7 +22,7 @@ import LatestBlocksIcon from './latest_blocks.png' import LatestTransactionsIcon from './latest_transactions.png' import { BlockCardItem, TransactionCardItem } from './TableCard' import Loading from '../../components/Loading/SmallLoading' -import { useElementIntersecting, useIsLGScreen, useIsMobile } from '../../utils/hook' +import { useElementIntersecting, useIsLGScreen, useIsMobile, useSingleHalving } from '../../utils/hook' import Banner from '../../components/Banner' import { HalvingBanner } from '../../components/Banner/HalvingBanner' import Search from '../../components/Search' @@ -226,12 +226,16 @@ export default () => { () => transactionsQuery.data?.transactions.slice(0, maxDisplaysCount) ?? [], [transactionsQuery.data?.transactions], ) + const { currentEpoch, targetEpoch } = useSingleHalving() + const isHalvingHidden = + currentEpoch > targetEpoch + 6 && // 6 epochs(1 day) after halving + currentEpoch < targetEpoch + EPOCHS_PER_HALVING - 180 // 180 epochs(30 days) before next halving const blockchainDataList = useBlockchainDataList(isMobile, isLG) return ( - {isMainnet() ? : } + {isMainnet() && !isHalvingHidden ? : }
diff --git a/src/utils/hook.ts b/src/utils/hook.ts index 4b2f14984..2dfd70508 100644 --- a/src/utils/hook.ts +++ b/src/utils/hook.ts @@ -649,11 +649,11 @@ export const useSingleHalving = (_halvingCount = 1) => { export const useHalving = () => { const statistics = useStatistics() const currentEpoch = Number(statistics.epochInfo.epochNumber) - const lastedHalvingCount = Math.ceil((currentEpoch + 1) / EPOCHS_PER_HALVING) - const lastedHalving = useSingleHalving(lastedHalvingCount) - const previousHalving = useSingleHalving(lastedHalvingCount - 1) + const nextHalvingCount = Math.ceil((currentEpoch + 1) / EPOCHS_PER_HALVING) + const nextHalving = useSingleHalving(nextHalvingCount) + const previousHalving = useSingleHalving(nextHalvingCount - 1) - return previousHalving.inCelebration ? previousHalving : lastedHalving + return previousHalving.inCelebration ? previousHalving : nextHalving } export default {