Skip to content

Commit

Permalink
chore: add coming soon buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
PainterPuppets committed Nov 15, 2023
1 parent fce3bd3 commit 6fab5c8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/components/Banner/HalvingBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function numberToOrdinal(number: number) {

export const HalvingBanner = () => {
const { estimatedDate, halvingCount, inCelebration, isLoading } = useHalving()
const [days, hours, minutes, seconds, expired] = useCountdown(estimatedDate)
const [days, hours, minutes, seconds, countdown] = useCountdown(estimatedDate)
const isMobile = useIsMobile()
const [t, { language }] = useTranslation()

Expand All @@ -60,7 +60,7 @@ export const HalvingBanner = () => {
return t('halving.learn_more')
}

if (expired) {
if (countdown <= 3) {
return t('halving.comming_soon')
}

Expand Down
4 changes: 2 additions & 2 deletions src/pages/Halving/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const HalvingCountdownPage = () => {
(((currentEpoch % EPOCHS_PER_HALVING) * THEORETICAL_EPOCH_TIME - currentEpochUsedTime) /
(EPOCHS_PER_HALVING * THEORETICAL_EPOCH_TIME)) *
100
const [days, hours, minutes, seconds, expired] = useCountdown(estimatedDate)
const [days, hours, minutes, seconds, countdown] = useCountdown(estimatedDate)

const shortCountdown = () => {
if (days > 0) {
Expand Down Expand Up @@ -132,7 +132,7 @@ export const HalvingCountdownPage = () => {
)
}

if (expired) {
if (countdown <= 3) {
return (
<div className={styles.halvingPanelWrapper}>
<div className={classnames(styles.halvingPanel, styles.loadingPanel)}>
Expand Down
6 changes: 3 additions & 3 deletions src/utils/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ export function useParsedDate(timestamp: number): string {
return parseDate(timestamp, now)
}

export const useCountdown = (targetDate: Date): [number, number, number, number, boolean] => {
export const useCountdown = (targetDate: Date): [number, number, number, number, number] => {
const countdownDate = new Date(targetDate).getTime()

const [countdown, setCountdown] = useState(countdownDate - new Date().getTime())
Expand All @@ -556,7 +556,7 @@ export const useCountdown = (targetDate: Date): [number, number, number, number,
const minutes = expired ? 0 : Math.floor((countdown % (1000 * 60 * 60)) / (1000 * 60))
const seconds = expired ? 0 : Math.floor((countdown % (1000 * 60)) / 1000)

return [days, hours, minutes, seconds, expired]
return [days, hours, minutes, seconds, countdown]
}

export const useCurrentEpochOverTime = (theoretical: boolean) => {
Expand Down Expand Up @@ -617,7 +617,7 @@ export const useSingleHalving = (_halvingCount = 1) => {

// special handling for last epoch: https://github.com/Magickbase/ckb-explorer-public-issues/issues/483
const { currentEpochEstimatedTime, currentEpochUsedTime, isLoading } = useCurrentEpochOverTime(
!(currentEpoch === targetEpoch - 1 && epochBlockIndex / epochLength > 0.5),
!(currentEpoch === targetEpoch - 1 && epochBlockIndex / epochLength > 0.2),
)

const estimatedTime = currentEpochEstimatedTime + THEORETICAL_EPOCH_TIME * (targetEpoch - currentEpoch - 1)
Expand Down

0 comments on commit 6fab5c8

Please sign in to comment.