diff options
author | Kevin Serrano <kevgagser@gmail.com> | 2017-03-11 01:34:13 +0800 |
---|---|---|
committer | Kevin Serrano <kevgagser@gmail.com> | 2017-03-11 01:34:13 +0800 |
commit | 2ab86b001dfc4ade4fc6df030175e64359b757e6 (patch) | |
tree | dd552767149226c535f48be7de6365ffd55dee8e /app/scripts/controllers | |
parent | b34ee4daa145c1d4eea2da6fd0cba0763e5c6483 (diff) | |
download | tangerine-wallet-browser-2ab86b001dfc4ade4fc6df030175e64359b757e6.tar tangerine-wallet-browser-2ab86b001dfc4ade4fc6df030175e64359b757e6.tar.gz tangerine-wallet-browser-2ab86b001dfc4ade4fc6df030175e64359b757e6.tar.bz2 tangerine-wallet-browser-2ab86b001dfc4ade4fc6df030175e64359b757e6.tar.lz tangerine-wallet-browser-2ab86b001dfc4ade4fc6df030175e64359b757e6.tar.xz tangerine-wallet-browser-2ab86b001dfc4ade4fc6df030175e64359b757e6.tar.zst tangerine-wallet-browser-2ab86b001dfc4ade4fc6df030175e64359b757e6.zip |
Add comments.
Diffstat (limited to 'app/scripts/controllers')
-rw-r--r-- | app/scripts/controllers/address-book.js | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/app/scripts/controllers/address-book.js b/app/scripts/controllers/address-book.js index 3c2a73dd7..a75ef06ce 100644 --- a/app/scripts/controllers/address-book.js +++ b/app/scripts/controllers/address-book.js @@ -3,6 +3,10 @@ const extend = require('xtend') class AddressBookController { + + // Controller in charge of managing the address book functionality from the + // recipients field on the send screen. Manages a history of all saved + // addresses and all currently owned addresses. constructor (opts = {}) { const initState = extend({ addressBook: [], @@ -14,8 +18,9 @@ class AddressBookController { // PUBLIC METHODS // + // Sets a new address book in store by accepting a new address and nickname. setAddressBook (address, name) { - return this.addToAddressBook(address, name) + return this._addToAddressBook(address, name) .then((addressBook) => { this.store.updateState({ addressBook, @@ -24,8 +29,16 @@ class AddressBookController { }) } - addToAddressBook (address, name) { - let addressBook = this.getAddressBook() + // + // PRIVATE METHODS + // + + + // Performs the logic to add the address and name into the address book. The + // pushed object is an object of two fields. Current behavior does not set an + // upper limit to the number of addresses. + _addToAddressBook (address, name) { + let addressBook = this._getAddressBook() let index = addressBook.findIndex((element) => { return element.address === address || element.name === name }) if (index !== -1) { addressBook.splice(index, 1) @@ -37,7 +50,9 @@ class AddressBookController { return Promise.resolve(addressBook) } - getAddressBook () { + // Internal method to get the address book. Current persistence behavior + // should not require that this method be called from the UI directly. + _getAddressBook () { return this.store.getState().addressBook } |