From 62854398f1d3c72a82ae9d4feb03d9a1a947534e Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Thu, 23 Feb 2017 13:56:58 -0800 Subject: Tested against code to play nice with unit tests. --- app/scripts/lib/controllers/preferences.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'app/scripts/lib') diff --git a/app/scripts/lib/controllers/preferences.js b/app/scripts/lib/controllers/preferences.js index 8cc320179..7bd2e5631 100644 --- a/app/scripts/lib/controllers/preferences.js +++ b/app/scripts/lib/controllers/preferences.js @@ -25,6 +25,14 @@ class PreferencesController { return this.store.getState().selectedAddress } + updateFrequentRpcList (_url) { + return this.addToFrequentRpcList(_url) + .then((rpcList) => { + this.store.updateState({ frequentRpcList: rpcList }) + return rpcList + }) + } + addToFrequentRpcList (_url) { let rpcList = this.getFrequentRpcList() let index = rpcList.findIndex((element) => { return element === _url }) @@ -37,8 +45,7 @@ class PreferencesController { if (rpcList.length > 2) { rpcList.shift() } - this.store.updateState({ frequentRpcList: rpcList }) - return Promise.resolve() + return Promise.resolve(rpcList) } getFrequentRpcList () { @@ -49,6 +56,8 @@ class PreferencesController { // PRIVATE METHODS // + + } module.exports = PreferencesController -- cgit