diff --git a/packages/web/src/new/scenes/Main/Send/Send.ViewModel.ts b/packages/web/src/new/scenes/Main/Send/Send.ViewModel.ts index 2c05d0b1..ae27a9a3 100644 --- a/packages/web/src/new/scenes/Main/Send/Send.ViewModel.ts +++ b/packages/web/src/new/scenes/Main/Send/Send.ViewModel.ts @@ -184,6 +184,7 @@ export class SendViewModel this.chooseTokenAndAmountViewModel.initialize(); this.selectAddressViewModel.initialize(); this.choosePayingWalletViewModel.initialize(); + this.walletsRepository.reload(); this._bind(); this.reload(); diff --git a/packages/web/src/new/scenes/Main/Swap/Swap/Swap.ViewModel.ts b/packages/web/src/new/scenes/Main/Swap/Swap/Swap.ViewModel.ts index 2765e375..cde12976 100644 --- a/packages/web/src/new/scenes/Main/Swap/Swap/Swap.ViewModel.ts +++ b/packages/web/src/new/scenes/Main/Swap/Swap/Swap.ViewModel.ts @@ -158,6 +158,7 @@ export class SwapViewModel extends ViewModel implements SwapViewModelType { this.chooseSourceWalletViewModel.initialize(); this.chooseDestinationWalletViewModel.initialize(); this.swapSettingsViewModel.initialize(); + this._walletsRepository.reload(); // TODO: really wait until wallets load? this.addReaction( diff --git a/packages/web/src/new/services/Repositories/WalletsRepository.ts b/packages/web/src/new/services/Repositories/WalletsRepository.ts index 156bf73a..d8a1cdb4 100644 --- a/packages/web/src/new/services/Repositories/WalletsRepository.ts +++ b/packages/web/src/new/services/Repositories/WalletsRepository.ts @@ -20,6 +20,7 @@ export class WalletsRepository extends SDListViewModel { // Properties private _timer?: NodeJS.Timeout; + private _wasRequested = false; // Getters @@ -67,6 +68,12 @@ export class WalletsRepository extends SDListViewModel { this._stopObserving(); } + override reload(): void { + if (!this._wasRequested) { + super.reload(); + } + } + // Binding private _bind(): void { // observe prices @@ -129,6 +136,8 @@ export class WalletsRepository extends SDListViewModel { override createRequest = flow(function* ( this: WalletsRepository, ): Generator> { + this._wasRequested = true; + return yield Promise.all([ // TODO: encapsulate address to service this._solanaService.provider.connection.getBalance( @@ -171,6 +180,8 @@ export class WalletsRepository extends SDListViewModel { }); private _getNewWallets(): Promise { + this._wasRequested = true; + return this._solanaService .getTokenWallets(this._solanaService.provider.wallet.publicKey.toString()) .then((wallets) => {