mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 18:00:18 +01:00
correct behavior when notification is closed when popup
This commit is contained in:
parent
2ace30bcd1
commit
bb868f5834
@ -237,7 +237,7 @@ class PreferencesController {
|
||||
removeSuggestedTokens () {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.store.updateState({ suggestedTokens: {} })
|
||||
resolve()
|
||||
resolve({})
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -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})))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
})
|
||||
})
|
||||
}}
|
||||
>
|
||||
|
@ -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…
Reference in New Issue
Block a user