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

Format block height with commas #2627

Merged
merged 2 commits into from
Dec 16, 2024
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
27 changes: 19 additions & 8 deletions views/NetworkInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Screen from '../components/Screen';

import { localeString } from '../utils/LocaleUtils';
import { themeColor } from '../utils/ThemeUtils';
import { numberWithCommas } from '../utils/UnitsUtils';

import NodeInfoStore from '../stores/NodeInfoStore';

Expand All @@ -32,27 +33,33 @@ export default class NetworkInfo extends React.Component<NetworkInfoProps, {}> {
const NETWORK_INFO = [
{
label: 'views.NetworkInfo.numChannels',
value: networkInfo.num_channels || 0
value: networkInfo.num_channels || 0,
formatValue: true
},
{
label: 'views.NetworkInfo.numNodes',
value: networkInfo.num_nodes || 0
value: networkInfo.num_nodes || 0,
formatValue: true
},
{
label: 'views.NetworkInfo.numZombieChannels',
value: networkInfo.num_zombie_chans || 0
value: networkInfo.num_zombie_chans || 0,
formatValue: true
},
{
label: 'views.NetworkInfo.graphDiameter',
value: networkInfo.graph_diameter || 0
value: networkInfo.graph_diameter || 0,
formatValue: false
},
{
label: 'views.NetworkInfo.averageOutDegree',
value: networkInfo.avg_out_degree || 0
value: networkInfo.avg_out_degree || 0,
formatValue: false
},
{
label: 'views.NetworkInfo.maxOutDegree',
value: networkInfo.max_out_degree || 0
value: networkInfo.max_out_degree || 0,
formatValue: false
}
];

Expand All @@ -75,10 +82,14 @@ export default class NetworkInfo extends React.Component<NetworkInfoProps, {}> {
renderItem={({ item }) => (
<KeyValue
keyValue={localeString(item.label)}
value={item.value}
value={
item.formatValue
? numberWithCommas(item.value)
: item.value
}
/>
)}
onRefresh={() => getNetworkInfo}
onRefresh={() => getNetworkInfo()}
refreshing={loading}
style={styles.content}
/>
Expand Down
3 changes: 2 additions & 1 deletion views/NodeInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Screen from '../components/Screen';
import { version } from '../package.json';
import { localeString } from '../utils/LocaleUtils';
import { themeColor } from '../utils/ThemeUtils';
import { numberWithCommas } from '../utils/UnitsUtils';

import NodeInfoStore from '../stores/NodeInfoStore';
import SettingsStore from '../stores/SettingsStore';
Expand Down Expand Up @@ -125,7 +126,7 @@ export default class NodeInfo extends React.Component<NodeInfoProps, {}> {
{nodeInfo.currentBlockHeight && (
<KeyValue
keyValue={localeString('views.NodeInfo.blockHeight')}
value={nodeInfo.currentBlockHeight}
value={numberWithCommas(nodeInfo.currentBlockHeight)}
/>
)}

Expand Down
7 changes: 4 additions & 3 deletions views/Sync.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import SyncStore from '../stores/SyncStore';

import { localeString } from '../utils/LocaleUtils';
import { themeColor } from '../utils/ThemeUtils';
import { numberWithCommas } from '../utils/UnitsUtils';

interface SyncProps {
navigation: StackNavigationProp<any, any>;
Expand Down Expand Up @@ -90,21 +91,21 @@ export default class Sync extends React.PureComponent<SyncProps, {}> {
keyValue={localeString(
'views.Sync.currentBlockHeight'
)}
value={currentBlockHeight}
value={numberWithCommas(currentBlockHeight)}
/>
)}
{bestBlockHeight && (
<KeyValue
keyValue={localeString('views.Sync.tip')}
value={bestBlockHeight}
value={numberWithCommas(bestBlockHeight)}
/>
)}
{!!numBlocksUntilSynced && (
<KeyValue
keyValue={localeString(
'views.Sync.numBlocksUntilSynced'
)}
value={numBlocksUntilSynced}
value={numberWithCommas(numBlocksUntilSynced)}
/>
)}
</View>
Expand Down
Loading