Skip to content

Commit 543ca27

Browse files
authored
Merge pull request #3106 from input-output-hk/fix/ddw-1190-fix-percentage-decimals
2 parents 16e259f + 38058df commit 543ca27

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## vNext
44

5+
### Fixes
6+
7+
- Fixed decimals for syncing percentage ([PR 3106](https://github.com/input-output-hk/daedalus/pull/3106))
8+
59
### Chores
610

711
- Updated `@cardano-foundation/ledgerjs-hw-app-cardano` to version `6.0.0` ([PR 3093](https://github.com/input-output-hk/daedalus/pull/3093))

source/main/utils/handleCheckBlockReplayProgress.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ const createHandleNewLogLine = (mainWindow: BrowserWindow) => {
6868
return;
6969
}
7070

71-
const progress = Math.floor(parseFloat(unparsedProgress));
71+
const progress = parseFloat(unparsedProgress);
7272

7373
if (progressReport[type] !== progress) {
7474
progressReport[type] = progress;

source/renderer/app/components/loading/syncing-connecting/SyncingProgress/SyncingProgress.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import cx from 'classnames';
22
import React from 'react';
3+
import BigNumber from 'bignumber.js';
34
import { intlShape } from 'react-intl';
45
import { PopOver } from 'react-polymorph/lib/components/PopOver';
56
import SVGInline from 'react-svg-inline';
@@ -13,6 +14,7 @@ import {
1314
getProgressDescriptionByBlockSyncType,
1415
getProgressNameByBlockSyncType,
1516
} from './utils';
17+
import { logger } from '../../../../utils/logging';
1618

1719
type Props = Record<BlockSyncType, number>;
1820

@@ -40,6 +42,17 @@ const makePercentageCellStyles = (loaded: boolean) =>
4042
[styles.faded]: loaded,
4143
});
4244

45+
const getSafePercentage = (value: number): string => {
46+
try {
47+
return new BigNumber(value).toFixed(2).toString();
48+
} catch (error) {
49+
logger.error('SyncingProgress::Percentage::Error parsing sync percentage', {
50+
error,
51+
});
52+
return '-';
53+
}
54+
};
55+
4356
function SyncingProgress(props: Props, { intl }: Context) {
4457
return (
4558
<div className={styles.root}>
@@ -80,7 +93,7 @@ function SyncingProgress(props: Props, { intl }: Context) {
8093
key={type}
8194
className={makePercentageCellStyles(props[type] === 100)}
8295
>
83-
{props[type]}%
96+
{getSafePercentage(props[type])}%
8497
</div>
8598
))}
8699
</div>

0 commit comments

Comments
 (0)