aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorKevin Serrano <kevgagser@gmail.com>2017-02-23 07:12:56 +0800
committerKevin Serrano <kevgagser@gmail.com>2017-02-23 07:12:56 +0800
commit7a0ce31bd31a3d6f1a92bbaded71b040ca765065 (patch)
treeb14e9b068ab1153660ad6c310c51478612ed52f9 /app
parent17a7436602191d11bb02771a87bd74f7baeb49ea (diff)
downloadtangerine-wallet-browser-7a0ce31bd31a3d6f1a92bbaded71b040ca765065.tar
tangerine-wallet-browser-7a0ce31bd31a3d6f1a92bbaded71b040ca765065.tar.gz
tangerine-wallet-browser-7a0ce31bd31a3d6f1a92bbaded71b040ca765065.tar.bz2
tangerine-wallet-browser-7a0ce31bd31a3d6f1a92bbaded71b040ca765065.tar.lz
tangerine-wallet-browser-7a0ce31bd31a3d6f1a92bbaded71b040ca765065.tar.xz
tangerine-wallet-browser-7a0ce31bd31a3d6f1a92bbaded71b040ca765065.tar.zst
tangerine-wallet-browser-7a0ce31bd31a3d6f1a92bbaded71b040ca765065.zip
Implemented functionality for displaying recent custom RPCs
Diffstat (limited to 'app')
-rw-r--r--app/scripts/lib/controllers/preferences.js29
1 files changed, 15 insertions, 14 deletions
diff --git a/app/scripts/lib/controllers/preferences.js b/app/scripts/lib/controllers/preferences.js
index b28f31b4b..8cc320179 100644
--- a/app/scripts/lib/controllers/preferences.js
+++ b/app/scripts/lib/controllers/preferences.js
@@ -1,10 +1,11 @@
const ObservableStore = require('obs-store')
const normalizeAddress = require('../sig-util').normalize
+const extend = require('xtend')
class PreferencesController {
constructor (opts = {}) {
- const initState = opts.initState || { frequentRPCList: [] }
+ const initState = extend({ frequentRpcList: [] }, opts.initState)
this.store = new ObservableStore(initState)
}
@@ -25,23 +26,23 @@ class PreferencesController {
}
addToFrequentRpcList (_url) {
- return new Promise((resolve, reject) => {
- let rpcList = this.getFrequentRPCList()
- let index = rpcList.findIndex((element) => { element === _url })
- if (index) {
- rpcList.splice(index, 1)
- }
- if (rpcList.length >= 3) {
- rpcList.shift()
- }
+ let rpcList = this.getFrequentRpcList()
+ let index = rpcList.findIndex((element) => { return element === _url })
+ if (index !== -1) {
+ rpcList.splice(index, 1)
+ }
+ if (_url !== 'http://localhost:8545') {
rpcList.push(_url)
- this.store.updateState({ frequentRPCList: rpcList })
- resolve()
- })
+ }
+ if (rpcList.length > 2) {
+ rpcList.shift()
+ }
+ this.store.updateState({ frequentRpcList: rpcList })
+ return Promise.resolve()
}
getFrequentRpcList () {
- return this.store.getState().frequentRPCList
+ return this.store.getState().frequentRpcList
}
//