Skip to content

Commit 50fceca

Browse files
committed
[DDW-1190] Created a function to force the syncing percentage to have 2 fixed digit places
1 parent 48ef792 commit 50fceca

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
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 ](https://github.com/input-output-hk/daedalus/pull/))
8+
59
## 5.2.0
610

711
### Features

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

Lines changed: 10 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';
@@ -40,6 +41,14 @@ const makePercentageCellStyles = (loaded: boolean) =>
4041
[styles.faded]: loaded,
4142
});
4243

44+
const getSafePercentage = (value: number): string => {
45+
try {
46+
return new BigNumber(value).toFixed(2).toString();
47+
} catch (error) {
48+
return '-';
49+
}
50+
};
51+
4352
function SyncingProgress(props: Props, { intl }: Context) {
4453
return (
4554
<div className={styles.root}>
@@ -80,7 +89,7 @@ function SyncingProgress(props: Props, { intl }: Context) {
8089
key={type}
8190
className={makePercentageCellStyles(props[type] === 100)}
8291
>
83-
{props[type]}%
92+
{getSafePercentage(props[type])}%
8493
</div>
8594
))}
8695
</div>

0 commit comments

Comments
 (0)