diff options
correct behavior when notification is closed when popup
Diffstat (limited to 'ui')
4 files changed, 23 insertions, 16 deletions
diff --git a/ui/app/actions.js b/ui/app/actions.js index 4e3c87756..0760377c2 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -1626,16 +1626,21 @@ function addTokens (tokens) { function removeSuggestedTokens () { return (dispatch) => { dispatch(actions.showLoadingIndication()) - background.removeSuggestedTokens((err) => { - dispatch(actions.hideLoadingIndication()) - if (err) { - dispatch(actions.displayWarning(err.message)) - } - dispatch(actions.clearPendingTokens()) - if (global.METAMASK_UI_TYPE === ENVIRONMENT_TYPE_NOTIFICATION) { - return global.platform.closeCurrentWindow() - } + return new Promise((resolve, reject) => { + background.removeSuggestedTokens((err, suggestedTokens) => { + dispatch(actions.hideLoadingIndication()) + if (err) { + dispatch(actions.displayWarning(err.message)) + } + dispatch(actions.clearPendingTokens()) + if (global.METAMASK_UI_TYPE === ENVIRONMENT_TYPE_NOTIFICATION) { + return global.platform.closeCurrentWindow() + } + resolve(suggestedTokens) + }) }) + .then(() => updateMetamaskStateFromBackground()) + .then(suggestedTokens => dispatch(actions.updateMetamaskState({...suggestedTokens}))) } } diff --git a/ui/app/components/pages/confirm-add-suggested-token/confirm-add-suggested-token.component.js b/ui/app/components/pages/confirm-add-suggested-token/confirm-add-suggested-token.component.js index e8155b5f0..37d9aca02 100644 --- a/ui/app/components/pages/confirm-add-suggested-token/confirm-add-suggested-token.component.js +++ b/ui/app/components/pages/confirm-add-suggested-token/confirm-add-suggested-token.component.js @@ -33,7 +33,7 @@ export default class ConfirmAddSuggestedToken extends Component { } render () { - const { addToken, clearPendingTokens, pendingTokens, removeSuggestedTokens, history } = this.props + const { addToken, pendingTokens, removeSuggestedTokens, history } = this.props const pendingTokenKey = Object.keys(pendingTokens)[0] const pendingToken = pendingTokens[pendingTokenKey] @@ -96,8 +96,10 @@ export default class ConfirmAddSuggestedToken extends Component { className="page-container__footer-button" onClick={() => { removeSuggestedTokens() - history.push(DEFAULT_ROUTE) - }} + .then(() => { + history.push(DEFAULT_ROUTE) + }) + }} > { this.context.t('cancel') } </Button> @@ -109,7 +111,9 @@ export default class ConfirmAddSuggestedToken extends Component { addToken(pendingToken) .then(() => { removeSuggestedTokens() - history.push(DEFAULT_ROUTE) + .then(() => { + history.push(DEFAULT_ROUTE) + }) }) }} > diff --git a/ui/app/components/pages/confirm-add-suggested-token/confirm-add-suggested-token.container.js b/ui/app/components/pages/confirm-add-suggested-token/confirm-add-suggested-token.container.js index 97e07afda..89291ff4f 100644 --- a/ui/app/components/pages/confirm-add-suggested-token/confirm-add-suggested-token.container.js +++ b/ui/app/components/pages/confirm-add-suggested-token/confirm-add-suggested-token.container.js @@ -5,7 +5,7 @@ import { withRouter } from 'react-router-dom' const extend = require('xtend') -const { addToken, clearPendingTokens, removeSuggestedTokens } = require('../../../actions') +const { addToken, removeSuggestedTokens } = require('../../../actions') const mapStateToProps = ({ metamask }) => { const { pendingTokens, suggestedTokens } = metamask @@ -19,7 +19,6 @@ const mapStateToProps = ({ metamask }) => { const mapDispatchToProps = dispatch => { return { addToken: ({address, symbol, decimals, imageUrl}) => dispatch(addToken(address, symbol, decimals, imageUrl)), - clearPendingTokens: () => dispatch(clearPendingTokens()), removeSuggestedTokens: () => dispatch(removeSuggestedTokens()), } } diff --git a/ui/app/components/pages/home.js b/ui/app/components/pages/home.js index 629dc11fc..6ee083579 100644 --- a/ui/app/components/pages/home.js +++ b/ui/app/components/pages/home.js @@ -40,7 +40,6 @@ class Home extends Component { // suggested new tokens if (Object.keys(suggestedTokens).length > 0) { - console.log('CALLING CONFIRM ADD SUGGESTED') history.push(CONFIRM_ADD_SUGGESTED_TOKEN_ROUTE) } |