aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app
diff options
context:
space:
mode:
authorbrunobar79 <brunobar79@gmail.com>2018-07-13 12:09:42 +0800
committerbrunobar79 <brunobar79@gmail.com>2018-07-13 12:09:42 +0800
commit289795fb1251f3d6bc2206efb2d640fcedae5ee4 (patch)
tree29414e76c29dac7a21e7166a9aa8da772465905b /ui/app
parent5710e648bd77aa7be6e9a4ba1d7d3fe4ea20c010 (diff)
downloadtangerine-wallet-browser-289795fb1251f3d6bc2206efb2d640fcedae5ee4.tar
tangerine-wallet-browser-289795fb1251f3d6bc2206efb2d640fcedae5ee4.tar.gz
tangerine-wallet-browser-289795fb1251f3d6bc2206efb2d640fcedae5ee4.tar.bz2
tangerine-wallet-browser-289795fb1251f3d6bc2206efb2d640fcedae5ee4.tar.lz
tangerine-wallet-browser-289795fb1251f3d6bc2206efb2d640fcedae5ee4.tar.xz
tangerine-wallet-browser-289795fb1251f3d6bc2206efb2d640fcedae5ee4.tar.zst
tangerine-wallet-browser-289795fb1251f3d6bc2206efb2d640fcedae5ee4.zip
fix account balance bug
Diffstat (limited to 'ui/app')
-rw-r--r--ui/app/components/modals/index.scss2
-rw-r--r--ui/app/components/pages/create-account/connect-hardware/index.js24
2 files changed, 16 insertions, 10 deletions
diff --git a/ui/app/components/modals/index.scss b/ui/app/components/modals/index.scss
index 1cefcb49c..e198cca44 100644
--- a/ui/app/components/modals/index.scss
+++ b/ui/app/components/modals/index.scss
@@ -53,7 +53,7 @@
}
&__link {
- margin-top: 16px;
+ margin-top: 14px;
img {
width: 15px;
diff --git a/ui/app/components/pages/create-account/connect-hardware/index.js b/ui/app/components/pages/create-account/connect-hardware/index.js
index 9aef36cfb..fa9cf4894 100644
--- a/ui/app/components/pages/create-account/connect-hardware/index.js
+++ b/ui/app/components/pages/create-account/connect-hardware/index.js
@@ -19,6 +19,18 @@ class ConnectHardwareForm extends Component {
}
}
+ componentWillReceiveProps (nextProps) {
+ const { accounts } = nextProps
+ const newAccounts = this.state.accounts.map(a => {
+ const normalizedAddress = a.address.toLowerCase()
+ const balanceValue = accounts[normalizedAddress] && accounts[normalizedAddress].balance || null
+ a.balance = balanceValue ? formatBalance(balanceValue, 6) : '...'
+ return a
+ })
+ this.setState({accounts: newAccounts})
+ }
+
+
async componentDidMount () {
const unlocked = await this.props.checkHardwareStatus('trezor')
if (unlocked) {
@@ -38,14 +50,6 @@ class ConnectHardwareForm extends Component {
this.setState({selectedAccount: account.toString(), error: null})
}
- getBalance (address) {
- // Get the balance
- const { accounts } = this.props
- const balanceValue = accounts && accounts[address.toLowerCase()] ? accounts[address.toLowerCase()].balance : ''
- const formattedBalance = balanceValue !== null ? formatBalance(balanceValue, 6) : '...'
- return formattedBalance
- }
-
getPage = (page) => {
this.props
.connectHardware('trezor', page)
@@ -64,7 +68,9 @@ class ConnectHardwareForm extends Component {
// Map accounts with balances
newState.accounts = accounts.map(account => {
- account.balance = this.getBalance(account.address)
+ const normalizedAddress = account.address.toLowerCase()
+ const balanceValue = this.props.accounts[normalizedAddress] && this.props.accounts[normalizedAddress].balance || null
+ account.balance = balanceValue ? formatBalance(balanceValue, 6) : '...'
return account
})