diff --git a/src/MainScreen.js b/src/MainScreen.js index 28231b0..f718428 100644 --- a/src/MainScreen.js +++ b/src/MainScreen.js @@ -11,7 +11,6 @@ import * as Animatable from 'react-native-animatable'; import QRCode from 'react-native-qrcode-svg'; import NativeLinking from "react-native/Libraries/Linking/NativeLinking"; import PushNotification from 'react-native-push-notification'; - import { NavigationActions, NavigationEvents, NavigationState } from 'react-navigation'; import { @@ -29,12 +28,11 @@ import { Address } from 'kryptokrona-utils'; import Config from './Config'; import { Styles } from './Styles'; -import { handleURI, toastPopUp } from './Utilities'; +import { handleURI, toastPopUp, prettyPrintAmountMainScreen } from './Utilities'; import { getBestCache, cacheSync, getKeyPair, getMessage, getExtra, optimizeMessages, intToRGB, hashCode, get_avatar } from './HuginUtilities'; import { ProgressBar } from './ProgressBar'; import { boardsMessageExists, getBoardsMessage, savePreferencesToDatabase, saveToDatabase, loadPayeeDataFromDatabase } from './Database'; import { Globals, initGlobals } from './Globals'; -import { reportCaughtException } from './Sentry'; import { processBlockOutputs, makePostRequest } from './NativeCode'; import { initBackgroundSync } from './BackgroundSync'; import { CopyButton, OneLineText } from './SharedComponents'; @@ -43,7 +41,6 @@ import { withTranslation } from 'react-i18next'; import './i18n.js'; import i18next from './i18n' - String.prototype.hashCode = function() { var hash = 0; if (this.length == 0) { @@ -476,24 +473,10 @@ export class MainScreen extends React.PureComponent { /> @@ -560,6 +543,7 @@ class AddressComponent extends React.PureComponent { name='Address' {...this.props} /> + 0) ? true : false; const compactBalance = this.setState({ - expandedBalance: !this.state.expandedBalance - })} > - {prettyPrintAmount(this.props.unlockedBalance + this.props.lockedBalance, Config).slice(0,-4)} + {prettyPrintAmountMainScreen(this.props.unlockedBalance)} ; const lockedBalance = @@ -818,10 +799,16 @@ class BalanceComponentNoTranslation extends React.Component { {this.state.expandedBalance ? expandedBalance : compactBalance} - + {parseInt(this.props.lockedBalance) > 0 && + + {prettyPrintAmount(this.props.lockedBalance, Config).slice(0,-4)}} + + {this.props.unlockedBalance && + {this.props.coinValue} + } + ); } @@ -930,7 +917,6 @@ async function backgroundSave() { await saveToDatabase(Globals.wallet); Globals.logger.addLogMessage('Save complete.'); } catch (err) { - reportCaughtException(err); Globals.logger.addLogMessage('Failed to background save: ' + err); } } diff --git a/src/Utilities.js b/src/Utilities.js index ec805c1..952f51f 100644 --- a/src/Utilities.js +++ b/src/Utilities.js @@ -388,3 +388,21 @@ export function validAmount(amount, unlockedBalance) { return [true, '']; } + +export function prettyPrintAmountMainScreen(amount) { + + // Get float with 5 decimals + amount = parseFloat(amount / (10 ** Config.decimalPlaces)).toFixed(5); + + if (amount.toString().split('.')[0].length > 6) { + // More than 100K XKR + amount = amount.toString().split('.')[0]; + } else if (amount.toString().split('.')[0].length < 4) { + // Less than 1K XKR + amount = amount; + } else { + // Between 1K & 100K XKR + amount = amount.toString().split('.')[0] = amount.toString().slice(0,-3); + } + return amount; +}