diff options
author | HackyMiner <hackyminer@gmail.com> | 2018-09-29 03:53:58 +0800 |
---|---|---|
committer | Whymarrh Whitby <whymarrh.whitby@gmail.com> | 2018-09-29 03:53:58 +0800 |
commit | 13a1d4672045371f6366bf1fc48b77cb880eb4f8 (patch) | |
tree | 66b87722afe3b3adc528e71ead28dd007eb16c69 /app/scripts/controllers/preferences.js | |
parent | 49a3d52dd6cbfbbdfd700f7a8898516f11e19045 (diff) | |
download | tangerine-wallet-browser-13a1d4672045371f6366bf1fc48b77cb880eb4f8.tar tangerine-wallet-browser-13a1d4672045371f6366bf1fc48b77cb880eb4f8.tar.gz tangerine-wallet-browser-13a1d4672045371f6366bf1fc48b77cb880eb4f8.tar.bz2 tangerine-wallet-browser-13a1d4672045371f6366bf1fc48b77cb880eb4f8.tar.lz tangerine-wallet-browser-13a1d4672045371f6366bf1fc48b77cb880eb4f8.tar.xz tangerine-wallet-browser-13a1d4672045371f6366bf1fc48b77cb880eb4f8.tar.zst tangerine-wallet-browser-13a1d4672045371f6366bf1fc48b77cb880eb4f8.zip |
support editable customRPC (#5267)
* support editable customRPC #5246
* remove rpcList size restriction
Diffstat (limited to 'app/scripts/controllers/preferences.js')
-rw-r--r-- | app/scripts/controllers/preferences.js | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js index 928ebdf1f..fd6a4866d 100644 --- a/app/scripts/controllers/preferences.js +++ b/app/scripts/controllers/preferences.js @@ -375,11 +375,12 @@ class PreferencesController { * Gets an updated rpc list from this.addToFrequentRpcList() and sets the `frequentRpcList` to this update list. * * @param {string} _url The the new rpc url to add to the updated list + * @param {bool} remove Remove selected url * @returns {Promise<void>} Promise resolves with undefined * */ - updateFrequentRpcList (_url) { - return this.addToFrequentRpcList(_url) + updateFrequentRpcList (_url, remove = false) { + return this.addToFrequentRpcList(_url, remove) .then((rpcList) => { this.store.updateState({ frequentRpcList: rpcList }) return Promise.resolve() @@ -406,21 +407,19 @@ class PreferencesController { * end of the list. The current list is modified and returned as a promise. * * @param {string} _url The rpc url to add to the frequentRpcList. + * @param {bool} remove Remove selected url * @returns {Promise<array>} The updated frequentRpcList. * */ - addToFrequentRpcList (_url) { + addToFrequentRpcList (_url, remove = false) { const rpcList = this.getFrequentRpcList() const index = rpcList.findIndex((element) => { return element === _url }) if (index !== -1) { rpcList.splice(index, 1) } - if (_url !== 'http://localhost:8545') { + if (!remove && _url !== 'http://localhost:8545') { rpcList.push(_url) } - if (rpcList.length > 3) { - rpcList.shift() - } return Promise.resolve(rpcList) } |