Skip to content
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

Merged
merged 4 commits into from
Mar 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion source/main/utils/handleCheckBlockReplayProgress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const createHandleNewLogLine = (mainWindow: BrowserWindow) => {
return;
}

const progress = Math.floor(parseFloat(unparsedProgress));
const progress = parseFloat(unparsedProgress);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


if (progressReport[type] !== progress) {
progressReport[type] = progress;
Expand Down
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';
Expand All @@ -13,6 +14,7 @@ import {
getProgressDescriptionByBlockSyncType,
getProgressNameByBlockSyncType,
} from './utils';
import { logger } from '../../../../utils/logging';

type Props = Record<BlockSyncType, number>;

Expand Down Expand Up @@ -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 '-';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danielmain is this - a requirement or we can return e.g. 0% ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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" ?

Copy link
Contributor

@tomislavhoracek tomislavhoracek Mar 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm, yeah. Maybe we can keep it as is and show -. It is better than showing the error that we are not able to parse the data or, like you said, confuse users by showing 0%

}
};

function SyncingProgress(props: Props, { intl }: Context) {
return (
<div className={styles.root}>
Expand Down Expand Up @@ -80,7 +93,7 @@ function SyncingProgress(props: Props, { intl }: Context) {
key={type}
className={makePercentageCellStyles(props[type] === 100)}
>
{props[type]}%
{getSafePercentage(props[type])}%
</div>
))}
</div>
Expand Down