correct behavior when notification is closed when popup

feature/default_network_editable
Esteban MIno 6 years ago
parent 2ace30bcd1
commit bb868f5834
  1. 2
      app/scripts/controllers/preferences.js
  2. 7
      ui/app/actions.js
  3. 6
      ui/app/components/pages/confirm-add-suggested-token/confirm-add-suggested-token.component.js
  4. 3
      ui/app/components/pages/confirm-add-suggested-token/confirm-add-suggested-token.container.js
  5. 1
      ui/app/components/pages/home.js

@ -237,7 +237,7 @@ class PreferencesController {
removeSuggestedTokens () {
return new Promise((resolve, reject) => {
this.store.updateState({ suggestedTokens: {} })
resolve()
resolve({})
})
}

@ -1626,7 +1626,8 @@ function addTokens (tokens) {
function removeSuggestedTokens () {
return (dispatch) => {
dispatch(actions.showLoadingIndication())
background.removeSuggestedTokens((err) => {
return new Promise((resolve, reject) => {
background.removeSuggestedTokens((err, suggestedTokens) => {
dispatch(actions.hideLoadingIndication())
if (err) {
dispatch(actions.displayWarning(err.message))
@ -1635,7 +1636,11 @@ function removeSuggestedTokens () {
if (global.METAMASK_UI_TYPE === ENVIRONMENT_TYPE_NOTIFICATION) {
return global.platform.closeCurrentWindow()
}
resolve(suggestedTokens)
})
})
.then(() => updateMetamaskStateFromBackground())
.then(suggestedTokens => dispatch(actions.updateMetamaskState({...suggestedTokens})))
}
}

@ -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,7 +96,9 @@ export default class ConfirmAddSuggestedToken extends Component {
className="page-container__footer-button"
onClick={() => {
removeSuggestedTokens()
.then(() => {
history.push(DEFAULT_ROUTE)
})
}}
>
{ this.context.t('cancel') }
@ -109,8 +111,10 @@ export default class ConfirmAddSuggestedToken extends Component {
addToken(pendingToken)
.then(() => {
removeSuggestedTokens()
.then(() => {
history.push(DEFAULT_ROUTE)
})
})
}}
>
{ this.context.t('addToken') }

@ -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()),
}
}

@ -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)
}

Loading…
Cancel
Save