From 3d43eceb89ce0bc8ec81bb9c9da1d3d026b203cf Mon Sep 17 00:00:00 2001 From: Nikola Glumac Date: Tue, 30 Mar 2021 09:25:07 +0200 Subject: [PATCH] Revert wallet array changes --- source/renderer/app/stores/WalletsStore.js | 41 +++++++++------------- 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/source/renderer/app/stores/WalletsStore.js b/source/renderer/app/stores/WalletsStore.js index 0c35c63a6b..2688166d42 100644 --- a/source/renderer/app/stores/WalletsStore.js +++ b/source/renderer/app/stores/WalletsStore.js @@ -1,5 +1,4 @@ // @flow -import type { IObservableArray } from 'mobx'; import { observable, action, computed, runInAction, flow } from 'mobx'; import { get, find, findIndex, isEqual, includes } from 'lodash'; import { BigNumber } from 'bignumber.js'; @@ -146,11 +145,6 @@ export default class WalletsStore extends Store { @observable activeValue: ?BigNumber = null; @observable activePublicKey: ?string = null; - /* ------------ Wallet Arrays ---------- */ - @observable all: IObservableArray = []; - @observable allWallets: IObservableArray = []; - @observable allLegacyWallets: IObservableArray = []; - /* ------------ Currencies ----------- */ @observable currencyIsFetchingList: boolean = false; @observable currencyIsFetchingRate: boolean = false; @@ -233,7 +227,7 @@ export default class WalletsStore extends Store { this.registerReactions([ this._updateActiveWalletOnRouteChanges, - this._updateWalletArraysOnRequestUpdate, + // this._updateWalletArraysOnRequestUpdate, ]); const { @@ -948,6 +942,22 @@ export default class WalletsStore extends Store { return this.all.length >= MAX_ADA_WALLETS_COUNT; } + @computed get all(): Array { + return [...this.allWallets, ...this.allLegacyWallets]; + } + + @computed get allWallets(): Array { + return this.walletsRequest.result + ? this.walletsRequest.result.filter(({ isLegacy }: Wallet) => !isLegacy) + : []; + } + + @computed get allLegacyWallets(): Array { + return this.walletsRequest.result + ? this.walletsRequest.result.filter(({ isLegacy }: Wallet) => isLegacy) + : []; + } + @computed get first(): ?Wallet { return this.all.length > 0 ? this.all[0] : null; } @@ -1074,23 +1084,6 @@ export default class WalletsStore extends Store { }); }; - _updateWalletArraysOnRequestUpdate = () => { - const walletsResult = this.walletsRequest.result; - runInAction(() => { - this.allWallets.replace( - walletsResult - ? walletsResult.filter(({ isLegacy }: Wallet) => !isLegacy) - : [] - ); - this.allLegacyWallets.replace( - walletsResult - ? walletsResult.filter(({ isLegacy }: Wallet) => isLegacy) - : [] - ); - this.all.replace(this.allWallets.concat(this.allLegacyWallets)); - }); - }; - isValidAddress = async (address: string) => { const { isIncentivizedTestnet, isShelleyTestnet } = global; const { isMainnet, isSelfnode, isStaging, isTestnet } = this.environment;