Skip to content

Commit

Permalink
Don't print "0" when viewing epoch snapshot on first block in an epoch
Browse files Browse the repository at this point in the history
When completedBlocksInCurrentEpoch = 0:
- percentageValue = 0
- `{percentageValue && (` evaluates to falsy and prints "0"
  • Loading branch information
lukaw3d committed Oct 22, 2024
1 parent 2955d9d commit 78df93a
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions .changelog/1581.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Don't print "0" when viewing epoch snapshot on first block in an epoch
8 changes: 4 additions & 4 deletions src/app/pages/ConsensusDashboardPage/SnapshotEpoch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const SnapshotEpoch: FC<{ scope: SearchScope }> = ({ scope }) => {
<SnapshotTextCard
title={t('currentEpoch')}
label={
blockHeight && (
blockHeight !== undefined && (
<Box sx={{ display: 'flex', alignItems: 'center', gap: 3 }}>
<Typography sx={{ fontSize: 12, color: COLORS.grayMedium }}>
<Trans
Expand All @@ -57,16 +57,16 @@ export const SnapshotEpoch: FC<{ scope: SearchScope }> = ({ scope }) => {
)
}
>
{epoch && (
{epoch !== undefined && (
<>
{percentageValue && (
{percentageValue !== undefined && (
<StyledBox>
<BrandProgressBar value={percentageValue * 100} variant="determinate" />
</StyledBox>
)}
<Box gap={3} sx={{ display: 'flex', alignItems: 'baseline' }}>
{epoch.toLocaleString()}
{percentageValue && (
{percentageValue !== undefined && (
<Typography sx={{ fontSize: 12, color: COLORS.grayMedium }}>
(
{t('common.valuePair', {
Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/ConsensusDashboardPage/SnapshotStaked.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const SnapshotStaked: FC<SnapshotStakedProps> = ({ totalStaked, ticker })
<SnapshotTextCard
title={t('common.staked')}
label={
percentageValue && (
percentageValue !== undefined && (
<Box sx={{ display: 'flex', alignItems: 'center', gap: 3 }}>
<Typography sx={{ fontSize: 12, color: COLORS.grayMedium }}>
<Trans
Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/ParatimeDashboardPage/Nodes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const Nodes: FC<{ scope: SearchScope }> = ({ scope }) => {
return (
<SnapshotCard title={title}>
<Box sx={{ display: 'flex', alignItems: 'center', justifyContent: 'center', height: '100%' }}>
{isFetched && activeNodes && (
{isFetched && activeNodes !== undefined && (
<>
<OfflineBoltIcon fontSize="large" sx={{ color: COLORS.eucalyptus, mr: 3 }} />
<Typography
Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/TokenDashboardPage/TokenDetailsCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export const TokenDetailsCard: FC<{ scope: SearchScope; address: string; searchT
</Link>
</dd>

{token.num_transfers && (
{!!token.num_transfers && (
<>
<dt>{t('common.transfers')}</dt>
<dd>
Expand Down

0 comments on commit 78df93a

Please sign in to comment.