aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/controllers/preferences.js
diff options
context:
space:
mode:
authorCsaba S <csaba.solya@gmail.com>2018-07-21 02:09:57 +0800
committerGitHub <noreply@github.com>2018-07-21 02:09:57 +0800
commitc11dea9afc9f4215529abda11a0d5a7e4fdd10d4 (patch)
tree9a21c102490c3a9c751c606008d1e0c10b20cdc2 /app/scripts/controllers/preferences.js
parent682d59cfe0114dc987fe5e953e9db4dca5e2b5d7 (diff)
parentcb045fd8feec88bd631329ab9b3285aeed0f2e97 (diff)
downloadtangerine-wallet-browser-c11dea9afc9f4215529abda11a0d5a7e4fdd10d4.tar
tangerine-wallet-browser-c11dea9afc9f4215529abda11a0d5a7e4fdd10d4.tar.gz
tangerine-wallet-browser-c11dea9afc9f4215529abda11a0d5a7e4fdd10d4.tar.bz2
tangerine-wallet-browser-c11dea9afc9f4215529abda11a0d5a7e4fdd10d4.tar.lz
tangerine-wallet-browser-c11dea9afc9f4215529abda11a0d5a7e4fdd10d4.tar.xz
tangerine-wallet-browser-c11dea9afc9f4215529abda11a0d5a7e4fdd10d4.tar.zst
tangerine-wallet-browser-c11dea9afc9f4215529abda11a0d5a7e4fdd10d4.zip
Merge branch 'develop' into transaction-notifications
Diffstat (limited to 'app/scripts/controllers/preferences.js')
-rw-r--r--app/scripts/controllers/preferences.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js
index b314745f5..f6250dc16 100644
--- a/app/scripts/controllers/preferences.js
+++ b/app/scripts/controllers/preferences.js
@@ -86,6 +86,30 @@ class PreferencesController {
}
/**
+ * Removes an address from state
+ *
+ * @param {string} address A hex address
+ * @returns {string} the address that was removed
+ */
+ removeAddress (address) {
+ const identities = this.store.getState().identities
+ if (!identities[address]) {
+ throw new Error(`${address} can't be deleted cause it was not found`)
+ }
+ delete identities[address]
+ this.store.updateState({ identities })
+
+ // If the selected account is no longer valid,
+ // select an arbitrary other account:
+ if (address === this.getSelectedAddress()) {
+ const selected = Object.keys(identities)[0]
+ this.setSelectedAddress(selected)
+ }
+ return address
+ }
+
+
+ /**
* Adds addresses to the identities object without removing identities
*
* @param {string[]} addresses An array of hex addresses