aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/controllers/preferences.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/scripts/controllers/preferences.js')
-rw-r--r--app/scripts/controllers/preferences.js8
1 files changed, 5 insertions, 3 deletions
diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js
index de9006044..39d15fd83 100644
--- a/app/scripts/controllers/preferences.js
+++ b/app/scripts/controllers/preferences.js
@@ -36,22 +36,24 @@ class PreferencesController {
return this.store.getState().selectedAddress
}
- addToken (rawAddress, symbol, decimals) {
+ async addToken (rawAddress, symbol, decimals) {
const address = normalizeAddress(rawAddress)
const newEntry = { address, symbol, decimals }
const tokens = this.store.getState().tokens
- const previousIndex = tokens.find((token, index) => {
+ const previousEntry = tokens.find((token, index) => {
return token.address === address
})
+ const previousIndex = tokens.indexOf(previousEntry)
- if (previousIndex) {
+ if (previousEntry) {
tokens[previousIndex] = newEntry
} else {
tokens.push(newEntry)
}
this.store.updateState({ tokens })
+
return Promise.resolve(tokens)
}