diff --git a/CHANGELOG.md b/CHANGELOG.md index aeea7ef1a1..f31b66cf8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## vNext +### Fixes + +- Fixed decimals for syncing percentage ([PR 3106](https://github.com/input-output-hk/daedalus/pull/3106)) + ### Chores - Updated `@cardano-foundation/ledgerjs-hw-app-cardano` to version `6.0.0` ([PR 3093](https://github.com/input-output-hk/daedalus/pull/3093)) diff --git a/source/main/utils/handleCheckBlockReplayProgress.ts b/source/main/utils/handleCheckBlockReplayProgress.ts index 3b615f4ca2..445d0197c1 100644 --- a/source/main/utils/handleCheckBlockReplayProgress.ts +++ b/source/main/utils/handleCheckBlockReplayProgress.ts @@ -68,7 +68,7 @@ const createHandleNewLogLine = (mainWindow: BrowserWindow) => { return; } - const progress = Math.floor(parseFloat(unparsedProgress)); + const progress = parseFloat(unparsedProgress); if (progressReport[type] !== progress) { progressReport[type] = progress; diff --git a/source/renderer/app/components/loading/syncing-connecting/SyncingProgress/SyncingProgress.tsx b/source/renderer/app/components/loading/syncing-connecting/SyncingProgress/SyncingProgress.tsx index b10a3c67f0..ec771fdcaa 100644 --- a/source/renderer/app/components/loading/syncing-connecting/SyncingProgress/SyncingProgress.tsx +++ b/source/renderer/app/components/loading/syncing-connecting/SyncingProgress/SyncingProgress.tsx @@ -1,5 +1,6 @@ import cx from 'classnames'; import React from 'react'; +import BigNumber from 'bignumber.js'; import { intlShape } from 'react-intl'; import { PopOver } from 'react-polymorph/lib/components/PopOver'; import SVGInline from 'react-svg-inline'; @@ -13,6 +14,7 @@ import { getProgressDescriptionByBlockSyncType, getProgressNameByBlockSyncType, } from './utils'; +import { logger } from '../../../../utils/logging'; type Props = Record<BlockSyncType, number>; @@ -40,6 +42,17 @@ const makePercentageCellStyles = (loaded: boolean) => [styles.faded]: loaded, }); +const getSafePercentage = (value: number): string => { + try { + return new BigNumber(value).toFixed(2).toString(); + } catch (error) { + logger.error('SyncingProgress::Percentage::Error parsing sync percentage', { + error, + }); + return '-'; + } +}; + function SyncingProgress(props: Props, { intl }: Context) { return ( <div className={styles.root}> @@ -80,7 +93,7 @@ function SyncingProgress(props: Props, { intl }: Context) { key={type} className={makePercentageCellStyles(props[type] === 100)} > - {props[type]}% + {getSafePercentage(props[type])}% </div> ))} </div>