-
Notifications
You must be signed in to change notification settings - Fork 295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DDW-1190] Set decimal places to 2 when showing the sync percentage #3106
Changes from all commits
50fceca
7d8dba9
f90b121
38058df
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 '-'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @danielmain is this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am uncertain if onParsingError we show 0% percentage sync. People will think they have to wait if they see 0% where there is actually an error. Should we show "Error parsing" ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmmm, yeah. Maybe we can keep it as is and show |
||
} | ||
}; | ||
|
||
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> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@przemyslaw-wlodek 👍