aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/controllers
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2018-10-21 11:51:00 +0800
committerkumavis <aaron@kumavis.me>2018-10-21 11:51:00 +0800
commitf0602ca354a6d352c13a79a1cba884f54e5b9a83 (patch)
tree39a993803aecae295956b6ab05c21d31d23f659f /app/scripts/controllers
parent73ec4e66cb7a476d01371a61692b0d8d9224da04 (diff)
parentba3617b685b9dcd8a62e0009ee2015c5997fead3 (diff)
downloadtangerine-wallet-browser-f0602ca354a6d352c13a79a1cba884f54e5b9a83.tar
tangerine-wallet-browser-f0602ca354a6d352c13a79a1cba884f54e5b9a83.tar.gz
tangerine-wallet-browser-f0602ca354a6d352c13a79a1cba884f54e5b9a83.tar.bz2
tangerine-wallet-browser-f0602ca354a6d352c13a79a1cba884f54e5b9a83.tar.lz
tangerine-wallet-browser-f0602ca354a6d352c13a79a1cba884f54e5b9a83.tar.xz
tangerine-wallet-browser-f0602ca354a6d352c13a79a1cba884f54e5b9a83.tar.zst
tangerine-wallet-browser-f0602ca354a6d352c13a79a1cba884f54e5b9a83.zip
Merge branch 'develop' of github.com:MetaMask/metamask-extension into sentry-enhancements2
Diffstat (limited to 'app/scripts/controllers')
-rw-r--r--app/scripts/controllers/preferences.js51
1 files changed, 25 insertions, 26 deletions
diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js
index 8eb2bce0c..689506a7a 100644
--- a/app/scripts/controllers/preferences.js
+++ b/app/scripts/controllers/preferences.js
@@ -375,22 +375,6 @@ 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, remove = false) {
- return this.addToFrequentRpcList(_url, remove)
- .then((rpcList) => {
- this.store.updateState({ frequentRpcList: rpcList })
- return Promise.resolve()
- })
- }
-
- /**
* Setter for the `currentAccountTab` property
*
* @param {string} currentAccountTab Specifies the new tab to be marked as current
@@ -405,24 +389,39 @@ class PreferencesController {
}
/**
- * Returns an updated rpcList based on the passed url and the current list.
- * The returned list will have a max length of 3. If the _url currently exists it the list, it will be moved to the
- * end of the list. The current list is modified and returned as a promise.
+ * Adds custom RPC url to state.
*
- * @param {string} _url The rpc url to add to the frequentRpcList.
- * @param {bool} remove Remove selected url
- * @returns {Promise<array>} The updated frequentRpcList.
+ * @param {string} url The RPC url to add to frequentRpcList.
+ * @returns {Promise<array>} Promise resolving to updated frequentRpcList.
*
*/
- addToFrequentRpcList (_url, remove = false) {
+ addToFrequentRpcList (url) {
const rpcList = this.getFrequentRpcList()
- const index = rpcList.findIndex((element) => { return element === _url })
+ const index = rpcList.findIndex((element) => { return element === url })
if (index !== -1) {
rpcList.splice(index, 1)
}
- if (!remove && _url !== 'http://localhost:8545') {
- rpcList.push(_url)
+ if (url !== 'http://localhost:8545') {
+ rpcList.push(url)
+ }
+ this.store.updateState({ frequentRpcList: rpcList })
+ return Promise.resolve(rpcList)
+ }
+
+ /**
+ * Removes custom RPC url from state.
+ *
+ * @param {string} url The RPC url to remove from frequentRpcList.
+ * @returns {Promise<array>} Promise resolving to updated frequentRpcList.
+ *
+ */
+ removeFromFrequentRpcList (url) {
+ const rpcList = this.getFrequentRpcList()
+ const index = rpcList.findIndex((element) => { return element === url })
+ if (index !== -1) {
+ rpcList.splice(index, 1)
}
+ this.store.updateState({ frequentRpcList: rpcList })
return Promise.resolve(rpcList)
}