diff options
author | Whymarrh Whitby <whymarrh.whitby@gmail.com> | 2018-04-19 11:33:51 +0800 |
---|---|---|
committer | Whymarrh Whitby <whymarrh.whitby@gmail.com> | 2018-05-17 23:27:39 +0800 |
commit | cbe4d0d88c83ee1d8dd8efde537ee753bf19596a (patch) | |
tree | d840a52d33e4729003cb5fb7b743364d286c869c /app/scripts/controllers | |
parent | 924cc1fcf7de1896ac09bbe7a400d5ff5df0b50d (diff) | |
download | tangerine-wallet-browser-cbe4d0d88c83ee1d8dd8efde537ee753bf19596a.tar tangerine-wallet-browser-cbe4d0d88c83ee1d8dd8efde537ee753bf19596a.tar.gz tangerine-wallet-browser-cbe4d0d88c83ee1d8dd8efde537ee753bf19596a.tar.bz2 tangerine-wallet-browser-cbe4d0d88c83ee1d8dd8efde537ee753bf19596a.tar.lz tangerine-wallet-browser-cbe4d0d88c83ee1d8dd8efde537ee753bf19596a.tar.xz tangerine-wallet-browser-cbe4d0d88c83ee1d8dd8efde537ee753bf19596a.tar.zst tangerine-wallet-browser-cbe4d0d88c83ee1d8dd8efde537ee753bf19596a.zip |
Update AddressBookController to read from preferences store
Diffstat (limited to 'app/scripts/controllers')
-rw-r--r-- | app/scripts/controllers/address-book.js | 27 |
1 files changed, 6 insertions, 21 deletions
diff --git a/app/scripts/controllers/address-book.js b/app/scripts/controllers/address-book.js index c91e6b2e4..4697e074c 100644 --- a/app/scripts/controllers/address-book.js +++ b/app/scripts/controllers/address-book.js @@ -13,19 +13,17 @@ class AddressBookController { * @param {object} opts Overrides the defaults for the initial state of this.store * @property {array} opts.initState initializes the the state of the AddressBookController. Can contain an * addressBook property to initialize the addressBook array - * @param {KeyringController} keyringController (Soon to be deprecated) The keyringController used in the current - * MetamaskController. Contains the identities used in this AddressBookController. + * @property {object} opts.preferencesStore the {@code PreferencesController} store * @property {object} store The the store of the current users address book * @property {array} store.addressBook An array of addresses and nicknames. These are set by the user when sending * to a new address. * */ - constructor (opts = {}, keyringController) { - const initState = extend({ + constructor ({initState, preferencesStore}) { + this.store = new ObservableStore(extend({ addressBook: [], - }, opts.initState) - this.store = new ObservableStore(initState) - this.keyringController = keyringController + }, initState)) + this._preferencesStore = preferencesStore } // @@ -62,7 +60,7 @@ class AddressBookController { */ _addToAddressBook (address, name) { const addressBook = this._getAddressBook() - const identities = this._getIdentities() + const {identities} = this._preferencesStore.getState() const addressBookIndex = addressBook.findIndex((element) => { return element.address.toLowerCase() === address.toLowerCase() || element.name === name }) const identitiesIndex = Object.keys(identities).findIndex((element) => { return element.toLowerCase() === address.toLowerCase() }) @@ -95,19 +93,6 @@ class AddressBookController { _getAddressBook () { return this.store.getState().addressBook } - - /** - * Retrieves identities from the keyring controller in order to avoid - * duplication - * - * @deprecated - * @returns {array} Returns the identies array from the keyringContoller's state - * - */ - _getIdentities () { - return this.keyringController.memStore.getState().identities - } - } module.exports = AddressBookController |