aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/controllers/preferences.js
diff options
context:
space:
mode:
authorKevin Serrano <kevgagser@gmail.com>2018-07-25 03:27:18 +0800
committerGitHub <noreply@github.com>2018-07-25 03:27:18 +0800
commit1d241bef768db85382e66885cd2661967ab4af1b (patch)
treec91c3ae9345b93bc35805b529320971234ecceda /app/scripts/controllers/preferences.js
parentdd9e3587d47c9a233cea5f7b305d8faa08ee6a0e (diff)
parentfed9ae0deed5853014cfc76b4314195d477f14f4 (diff)
downloadtangerine-wallet-browser-1d241bef768db85382e66885cd2661967ab4af1b.tar
tangerine-wallet-browser-1d241bef768db85382e66885cd2661967ab4af1b.tar.gz
tangerine-wallet-browser-1d241bef768db85382e66885cd2661967ab4af1b.tar.bz2
tangerine-wallet-browser-1d241bef768db85382e66885cd2661967ab4af1b.tar.lz
tangerine-wallet-browser-1d241bef768db85382e66885cd2661967ab4af1b.tar.xz
tangerine-wallet-browser-1d241bef768db85382e66885cd2661967ab4af1b.tar.zst
tangerine-wallet-browser-1d241bef768db85382e66885cd2661967ab4af1b.zip
Merge branch 'develop' into no-inject-ani-gamer
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