diff options
Enables remove token and ensures add/remove update the list without need for refresh.
Diffstat (limited to 'ui/app/actions.js')
-rw-r--r-- | ui/app/actions.js | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/ui/app/actions.js b/ui/app/actions.js index 1f3726f46..630b6390c 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -152,6 +152,9 @@ var actions = { showAddTokenPage, addToken, addTokens, + removeToken, + updateTokens, + UPDATE_TOKENS: 'UPDATE_TOKENS', setRpcTarget: setRpcTarget, setDefaultRpcTarget: setDefaultRpcTarget, setProviderType: setProviderType, @@ -753,16 +756,31 @@ function addToken (address, symbol, decimals) { return (dispatch) => { dispatch(actions.showLoadingIndication()) return new Promise((resolve, reject) => { - background.addToken(address, symbol, decimals, (err) => { + background.addToken(address, symbol, decimals, (err, tokens) => { dispatch(actions.hideLoadingIndication()) if (err) { dispatch(actions.displayWarning(err.message)) reject(err) } - resolve() - // setTimeout(() => { - // dispatch(actions.goHome()) - // }, 250) + dispatch(actions.updateTokens(tokens)) + resolve(tokens) + }) + }) + } +} + +function removeToken (address) { + return (dispatch) => { + dispatch(actions.showLoadingIndication()) + return new Promise((resolve, reject) => { + background.removeToken(address, (err, tokens) => { + dispatch(actions.hideLoadingIndication()) + if (err) { + dispatch(actions.displayWarning(err.message)) + reject(err) + } + dispatch(actions.updateTokens(tokens)) + resolve(tokens) }) }) } @@ -786,6 +804,13 @@ function addTokens (tokens) { } } +function updateTokens(newTokens) { + return { + type: actions.UPDATE_TOKENS, + newTokens + } +} + function goBackToInitView () { return { type: actions.BACK_TO_INIT_MENU, |