aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app
diff options
context:
space:
mode:
Diffstat (limited to 'ui/app')
-rw-r--r--ui/app/account-detail.js13
-rw-r--r--ui/app/actions.js25
-rw-r--r--ui/app/components/token-list.js15
3 files changed, 41 insertions, 12 deletions
diff --git a/ui/app/account-detail.js b/ui/app/account-detail.js
index 2e7f3b1be..836032b3c 100644
--- a/ui/app/account-detail.js
+++ b/ui/app/account-detail.js
@@ -34,12 +34,12 @@ function mapStateToProps (state) {
transactions: state.metamask.selectedAddressTxList || [],
conversionRate: state.metamask.conversionRate,
currentCurrency: state.metamask.currentCurrency,
+ currentAccountTab: state.metamask.currentAccountTab,
}
}
inherits(AccountDetailScreen, Component)
function AccountDetailScreen () {
- this.state = { tabSelection: 'history' }
Component.call(this)
}
@@ -251,7 +251,8 @@ AccountDetailScreen.prototype.subview = function () {
}
AccountDetailScreen.prototype.tabSections = function () {
- const tabSelection = this.state.tabSelection
+ const { currentAccountTab } = this.props
+
return h('section.tabSection', [
h(TabBar, {
@@ -259,9 +260,9 @@ AccountDetailScreen.prototype.tabSections = function () {
{ content: 'Sent', key: 'history' },
{ content: 'Tokens', key: 'tokens' },
],
- defaultTab: tabSelection || 'history',
+ defaultTab: currentAccountTab || 'history',
tabSelected: (key) => {
- this.setState({ tabSelection: key })
+ this.props.dispatch(actions.setCurrentAccountTab(key))
},
}),
@@ -272,9 +273,9 @@ AccountDetailScreen.prototype.tabSections = function () {
AccountDetailScreen.prototype.tabSwitchView = function () {
const props = this.props
const { address, network } = props
- const tabSelection = this.state.tabSelection || 'history'
+ const { currentAccountTab } = this.props
- switch (tabSelection) {
+ switch (currentAccountTab) {
case 'tokens':
return h(TokenList, { userAddress: address, network })
default:
diff --git a/ui/app/actions.js b/ui/app/actions.js
index 1a3557cb4..b6b5d6eb1 100644
--- a/ui/app/actions.js
+++ b/ui/app/actions.js
@@ -74,6 +74,7 @@ var actions = {
SHOW_CONF_MSG_PAGE: 'SHOW_CONF_MSG_PAGE',
SET_CURRENT_FIAT: 'SET_CURRENT_FIAT',
setCurrentCurrency: setCurrentCurrency,
+ setCurrentAccountTab,
// account detail screen
SHOW_SEND_PAGE: 'SHOW_SEND_PAGE',
showSendPage: showSendPage,
@@ -218,7 +219,7 @@ function confirmSeedWords () {
return dispatch(actions.displayWarning(err.message))
}
- console.log('Seed word cache cleared. ' + account)
+ log.info('Seed word cache cleared. ' + account)
dispatch(actions.showAccountDetail(account))
})
}
@@ -338,7 +339,7 @@ function setCurrentCurrency (currencyCode) {
background.setCurrentCurrency(currencyCode, (err, data) => {
dispatch(this.hideLoadingIndication())
if (err) {
- console.error(err.stack)
+ log.error(err.stack)
return dispatch(actions.displayWarning(err.message))
}
dispatch({
@@ -409,7 +410,7 @@ function sendTx (txData) {
background.approveTransaction(txData.id, (err) => {
if (err) {
dispatch(actions.txError(err))
- return console.error(err.message)
+ return log.error(err.message)
}
dispatch(actions.completedTx(txData.id))
})
@@ -424,7 +425,7 @@ function updateAndApproveTx (txData) {
dispatch(actions.hideLoadingIndication())
if (err) {
dispatch(actions.txError(err))
- return console.error(err.message)
+ return log.error(err.message)
}
dispatch(actions.completedTx(txData.id))
})
@@ -558,6 +559,11 @@ function lockMetamask () {
return callBackgroundThenUpdate(background.setLocked)
}
+function setCurrentAccountTab (newTabName) {
+ log.debug(`background.setCurrentAccountTab: ${newTabName}`)
+ return callBackgroundThenUpdateNoSpinner(background.setCurrentAccountTab, newTabName)
+}
+
function showAccountDetail (address) {
return (dispatch) => {
dispatch(actions.showLoadingIndication())
@@ -965,6 +971,17 @@ function shapeShiftRequest (query, options, cb) {
// We hide loading indication.
// If it errored, we show a warning.
// If it didn't, we update the state.
+function callBackgroundThenUpdateNoSpinner (method, ...args) {
+ return (dispatch) => {
+ method.call(background, ...args, (err) => {
+ if (err) {
+ return dispatch(actions.displayWarning(err.message))
+ }
+ forceUpdateMetamaskState(dispatch)
+ })
+ }
+}
+
function callBackgroundThenUpdate (method, ...args) {
return (dispatch) => {
dispatch(actions.showLoadingIndication())
diff --git a/ui/app/components/token-list.js b/ui/app/components/token-list.js
index b79fbccf3..66cbddeda 100644
--- a/ui/app/components/token-list.js
+++ b/ui/app/components/token-list.js
@@ -80,10 +80,21 @@ TokenList.prototype.componentDidMount = function () {
this.setState({ tokens: this.tracker.serialize() })
this.tracker.on('update', (tokenData) => {
- const heldTokens = tokenData.filter(token => token.balance !== '0' && token.string !== '0.000')
- this.setState({ tokens: heldTokens, isLoading: false })
+ this.updateBalances(tokenData)
})
this.tracker.updateBalances()
+ .then(() => {
+ this.updateBalances(this.tracker.serialize())
+ })
+ .catch((reason) => {
+ log.error(`Problem updating balances`, reason)
+ this.setState({ isLoading: false })
+ })
+}
+
+TokenList.prototype.updateBalances = function (tokenData) {
+ const heldTokens = tokenData.filter(token => token.balance !== '0' && token.string !== '0.000')
+ this.setState({ tokens: heldTokens, isLoading: false })
}
TokenList.prototype.componentWillUnmount = function () {