Skip to content

Commit

Permalink
Merge pull request #2627 from shubhamkmr04/shubham/format-with-commas
Browse files Browse the repository at this point in the history
Format block height with commas
  • Loading branch information
kaloudis authored Dec 16, 2024
2 parents 107e4df + 4e9fef7 commit 56cb0b5
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
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

0 comments on commit 56cb0b5

Please sign in to comment.