Skip to content

Commit

Permalink
Revert wallet array changes
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolaglumac committed Mar 30, 2021
1 parent 90d3609 commit 3d43ece
Showing 1 changed file with 17 additions and 24 deletions.
41 changes: 17 additions & 24 deletions source/renderer/app/stores/WalletsStore.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -146,11 +145,6 @@ export default class WalletsStore extends Store {
@observable activeValue: ?BigNumber = null;
@observable activePublicKey: ?string = null;

/* ------------ Wallet Arrays ---------- */
@observable all: IObservableArray<Wallet> = [];
@observable allWallets: IObservableArray<Wallet> = [];
@observable allLegacyWallets: IObservableArray<Wallet> = [];

/* ------------ Currencies ----------- */
@observable currencyIsFetchingList: boolean = false;
@observable currencyIsFetchingRate: boolean = false;
Expand Down Expand Up @@ -233,7 +227,7 @@ export default class WalletsStore extends Store {

this.registerReactions([
this._updateActiveWalletOnRouteChanges,
this._updateWalletArraysOnRequestUpdate,
// this._updateWalletArraysOnRequestUpdate,
]);

const {
Expand Down Expand Up @@ -948,6 +942,22 @@ export default class WalletsStore extends Store {
return this.all.length >= MAX_ADA_WALLETS_COUNT;
}

@computed get all(): Array<Wallet> {
return [...this.allWallets, ...this.allLegacyWallets];
}

@computed get allWallets(): Array<Wallet> {
return this.walletsRequest.result
? this.walletsRequest.result.filter(({ isLegacy }: Wallet) => !isLegacy)
: [];
}

@computed get allLegacyWallets(): Array<Wallet> {
return this.walletsRequest.result
? this.walletsRequest.result.filter(({ isLegacy }: Wallet) => isLegacy)
: [];
}

@computed get first(): ?Wallet {
return this.all.length > 0 ? this.all[0] : null;
}
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 3d43ece

Please sign in to comment.