From 6e9a32d486419d042d83f03e94c99d36af91dffc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20Mi=C3=B1o?= Date: Tue, 13 Nov 2018 14:57:15 -0300 Subject: [PATCH] Update PreferencesController state to handle references (#21) --- src/PreferencesController.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/PreferencesController.ts b/src/PreferencesController.ts index f5884ed9b2..48a4cb4f9f 100644 --- a/src/PreferencesController.ts +++ b/src/PreferencesController.ts @@ -108,7 +108,7 @@ export class PreferencesController extends BaseController { + const frequentRpcList = this.state.frequentRpcList; + const index = frequentRpcList.findIndex((element) => { return element === url; }); if (index !== -1) { - newFrequentRpcList.splice(index, 1); + frequentRpcList.splice(index, 1); } - newFrequentRpcList.push(url); - this.update({ frequentRpcList: newFrequentRpcList }); + frequentRpcList.push(url); + this.update({ frequentRpcList: [...frequentRpcList] }); } /** @@ -193,14 +193,14 @@ export class PreferencesController extends BaseController { + const frequentRpcList = this.state.frequentRpcList; + const index = frequentRpcList.findIndex((element) => { return element === url; }); if (index !== -1) { - newFrequentRpcList.splice(index, 1); + frequentRpcList.splice(index, 1); } - this.update({ frequentRpcList: newFrequentRpcList }); + this.update({ frequentRpcList: [...frequentRpcList] }); } }