Skip to content

Commit

Permalink
fix: fix frozen epoch time chart
Browse files Browse the repository at this point in the history
The type of data is number, but it's asserted to be string while
exception is not properly handled
  • Loading branch information
Keith-CY committed Nov 4, 2023
1 parent 634d0cc commit 462122c
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/pages/StatisticsChart/mining/DifficultyUncleRateEpoch.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { FC } from 'react'
import BigNumber from 'bignumber.js'
import { useTranslation } from 'react-i18next'
import { assertSerialsDataIsString, assertIsArray, assertSerialsItem, handleAxis } from '../../../utils/chart'
import { assertIsArray, assertSerialsItem, handleAxis } from '../../../utils/chart'
import { tooltipColor, tooltipWidth, SeriesItem, SmartChartPage } from '../common'
import { parseHourFromMillisecond } from '../../../utils/date'
import { ChartCachedKeys } from '../../../constants/cache'
Expand All @@ -15,11 +15,11 @@ const widthSpan = (value: string, currentLanguage: LanuageType) =>
const useTooltip = () => {
const { t } = useTranslation()
const currentLanguage = useCurrentLanguage()
return ({ seriesName, data, color }: SeriesItem & { data: string }) => {
if (seriesName === t('block.epoch_time')) {
return ({ seriesName, data, color }: SeriesItem & { data?: number }) => {
if (seriesName === t('block.epoch_time') && typeof data === 'number') {
return `<div>${tooltipColor(color)}${widthSpan(t('block.epoch_time'), currentLanguage)} ${data} h</div>`
}
if (seriesName === t('block.epoch_length')) {
if (seriesName === t('block.epoch_length') && typeof data === 'number') {
return `<div>${tooltipColor(color)}${widthSpan(t('block.epoch_length'), currentLanguage)} ${data}</div>`
}
return ''
Expand Down Expand Up @@ -71,7 +71,6 @@ const useOption = (
}</div>`
dataList.forEach(data => {
assertSerialsItem(data)
assertSerialsDataIsString(data)
result += parseTooltip(data)
})
return result
Expand Down

0 comments on commit 462122c

Please sign in to comment.