diff options
author | Dan <danjm.com@gmail.com> | 2017-10-04 01:25:52 +0800 |
---|---|---|
committer | Chi Kei Chan <chikeichan@gmail.com> | 2017-10-04 06:46:01 +0800 |
commit | ac4868170f4c61d13291389d01bf1002fe240ed4 (patch) | |
tree | d4000928e6b890d99d28b8109ad82cde7bf82fce /app/scripts | |
parent | 45dbd017e65e5698db4580c77d723bface0e9b63 (diff) | |
download | tangerine-wallet-browser-ac4868170f4c61d13291389d01bf1002fe240ed4.tar tangerine-wallet-browser-ac4868170f4c61d13291389d01bf1002fe240ed4.tar.gz tangerine-wallet-browser-ac4868170f4c61d13291389d01bf1002fe240ed4.tar.bz2 tangerine-wallet-browser-ac4868170f4c61d13291389d01bf1002fe240ed4.tar.lz tangerine-wallet-browser-ac4868170f4c61d13291389d01bf1002fe240ed4.tar.xz tangerine-wallet-browser-ac4868170f4c61d13291389d01bf1002fe240ed4.tar.zst tangerine-wallet-browser-ac4868170f4c61d13291389d01bf1002fe240ed4.zip |
Enables remove token and ensures add/remove update the list without need for refresh.
Diffstat (limited to 'app/scripts')
-rw-r--r-- | app/scripts/controllers/preferences.js | 13 | ||||
-rw-r--r-- | app/scripts/metamask-controller.js | 1 |
2 files changed, 13 insertions, 1 deletions
diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js index bc4848421..ecac40481 100644 --- a/app/scripts/controllers/preferences.js +++ b/app/scripts/controllers/preferences.js @@ -42,7 +42,18 @@ class PreferencesController { } this.store.updateState({ tokens }) - return Promise.resolve() + return Promise.resolve(tokens) + } + + removeToken (rawAddress) { + const address = normalizeAddress(rawAddress) + + const tokens = this.store.getState().tokens + + const updatedTokens = tokens.filter(token => token.address !== rawAddress) + + this.store.updateState({ tokens: updatedTokens }) + return Promise.resolve(updatedTokens) } getTokens () { diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 5b3161bc6..b5c81c348 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -327,6 +327,7 @@ module.exports = class MetamaskController extends EventEmitter { // PreferencesController setSelectedAddress: nodeify(preferencesController.setSelectedAddress, preferencesController), addToken: nodeify(preferencesController.addToken, preferencesController), + removeToken: nodeify(preferencesController.removeToken, preferencesController), setCurrentAccountTab: nodeify(preferencesController.setCurrentAccountTab, preferencesController), setDefaultRpc: nodeify(this.setDefaultRpc, this), setCustomRpc: nodeify(this.setCustomRpc, this), |