From 72a081ceca4bc7077a98278b27aa202a81795cf4 Mon Sep 17 00:00:00 2001 From: Cuteivist Date: Thu, 25 Apr 2024 11:08:19 +0200 Subject: [PATCH] fix(wallet): Update balance loading state on token fetched (#14491) --- src/app/modules/main/wallet_section/module.nim | 6 +++++- .../modules/main/wallet_section/overview/module.nim | 10 ++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/app/modules/main/wallet_section/module.nim b/src/app/modules/main/wallet_section/module.nim index 76b6f3ea0d..d415c25c91 100644 --- a/src/app/modules/main/wallet_section/module.nim +++ b/src/app/modules/main/wallet_section/module.nim @@ -209,6 +209,10 @@ proc notifyModulesOnFilterChanged(self: Module) = self.allCollectiblesModule.refreshWalletAccounts() self.assetsModule.filterChanged(self.filter.addresses, self.filter.chainIds) +proc notifyModulesBalanceIsLoaded(self: Module) = + self.overviewModule.filterChanged(self.filter.addresses, self.filter.chainIds) + self.accountsModule.filterChanged(self.filter.addresses, self.filter.chainIds) + proc updateViewWithAddressFilterChanged(self: Module) = if self.overviewModule.getIsAllAccounts(): self.view.filterChanged("") @@ -271,7 +275,7 @@ method load*(self: Module) = self.notifyFilterChanged() self.events.on(SIGNAL_WALLET_ACCOUNT_TOKENS_REBUILT) do(e:Args): self.setTotalCurrencyBalance() - # self.notifyFilterChanged() + self.notifyModulesBalanceIsLoaded() self.events.on(SIGNAL_TOKENS_PRICES_UPDATED) do(e:Args): self.setTotalCurrencyBalance() self.notifyFilterChanged() diff --git a/src/app/modules/main/wallet_section/overview/module.nim b/src/app/modules/main/wallet_section/overview/module.nim index a7acd2af50..0975e2ebf3 100644 --- a/src/app/modules/main/wallet_section/overview/module.nim +++ b/src/app/modules/main/wallet_section/overview/module.nim @@ -66,8 +66,13 @@ proc getWalletAccoutColors(self: Module, walletAccounts: seq[WalletAccountDto]) method filterChanged*(self: Module, addresses: seq[string], chainIds: seq[int]) = let walletAccounts = self.controller.getWalletAccountsByAddresses(addresses) - let walletAccount = walletAccounts[0] - let loading = walletAccounts[0].assetsLoading or self.controller.getTokensMarketValuesLoading() + if walletAccounts.len == 0: + return + var loading = self.controller.getTokensMarketValuesLoading() + for account in walletAccounts: + if account.assetsLoading: + loading = true + break if self.isAllAccounts: let item = initItem( "", @@ -82,6 +87,7 @@ method filterChanged*(self: Module, addresses: seq[string], chainIds: seq[int]) ) self.view.setData(item) else: + let walletAccount = walletAccounts[0] let isWatchOnlyAccount = walletAccount.walletType == "watch" let item = initItem( walletAccount.name,