diff options
author | Thomas Huang <tmashuang@users.noreply.github.com> | 2017-10-21 00:09:44 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-21 00:09:44 +0800 |
commit | e3a7da961dd01bcb936a000cdf62e2290a5024ef (patch) | |
tree | 516bd55226d160ec888627906884933894c016a4 /app/scripts/lib/account-tracker.js | |
parent | 87ad6a29f09763c1fa6910b36c946dc00dcf4b6c (diff) | |
parent | c24e266118b7db093a1db0b8c87c361011a16952 (diff) | |
download | tangerine-wallet-browser-e3a7da961dd01bcb936a000cdf62e2290a5024ef.tar tangerine-wallet-browser-e3a7da961dd01bcb936a000cdf62e2290a5024ef.tar.gz tangerine-wallet-browser-e3a7da961dd01bcb936a000cdf62e2290a5024ef.tar.bz2 tangerine-wallet-browser-e3a7da961dd01bcb936a000cdf62e2290a5024ef.tar.lz tangerine-wallet-browser-e3a7da961dd01bcb936a000cdf62e2290a5024ef.tar.xz tangerine-wallet-browser-e3a7da961dd01bcb936a000cdf62e2290a5024ef.tar.zst tangerine-wallet-browser-e3a7da961dd01bcb936a000cdf62e2290a5024ef.zip |
Merge pull request #2389 from MetaMask/i2348-SelectAccountOnNewVault
Select first account on create or restore vault
Diffstat (limited to 'app/scripts/lib/account-tracker.js')
-rw-r--r-- | app/scripts/lib/account-tracker.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/app/scripts/lib/account-tracker.js b/app/scripts/lib/account-tracker.js index cdc21282d..ce6642150 100644 --- a/app/scripts/lib/account-tracker.js +++ b/app/scripts/lib/account-tracker.js @@ -38,6 +38,29 @@ class AccountTracker extends EventEmitter { // public // + syncWithAddresses (addresses) { + const accounts = this.store.getState().accounts + const locals = Object.keys(accounts) + + const toAdd = [] + addresses.forEach((upstream) => { + if (!locals.includes(upstream)) { + toAdd.push(upstream) + } + }) + + const toRemove = [] + locals.forEach((local) => { + if (!addresses.includes(local)) { + toRemove.push(local) + } + }) + + toAdd.forEach(upstream => this.addAccount(upstream)) + toRemove.forEach(local => this.removeAccount(local)) + this._updateAccounts() + } + addAccount (address) { const accounts = this.store.getState().accounts accounts[address] = {} |