diff --git a/src/app/modules/main/wallet_section/all_tokens/flat_tokens_model.nim b/src/app/modules/main/wallet_section/all_tokens/flat_tokens_model.nim index 1b1e71774c..0074446564 100644 --- a/src/app/modules/main/wallet_section/all_tokens/flat_tokens_model.nim +++ b/src/app/modules/main/wallet_section/all_tokens/flat_tokens_model.nim @@ -128,12 +128,9 @@ QtObject: of ModelRole.MarketDetailsLoading: result = newQVariant(self.delegate.getTokensMarketValuesLoading()) - - proc modelsAboutToUpdate*(self: FlatTokensModel) = - self.tokenMarketDetails = @[] - self.beginResetModel() - proc modelsUpdated*(self: FlatTokensModel) = + self.beginResetModel() + self.tokenMarketDetails = @[] for token in self.delegate.getFlatTokensList(): let symbol = if token.communityId.isEmptyOrWhitespace: token.symbol else: "" diff --git a/src/app/modules/main/wallet_section/all_tokens/module.nim b/src/app/modules/main/wallet_section/all_tokens/module.nim index 3241fbb423..df7c547fca 100644 --- a/src/app/modules/main/wallet_section/all_tokens/module.nim +++ b/src/app/modules/main/wallet_section/all_tokens/module.nim @@ -49,8 +49,6 @@ method load*(self: Module) = self.controller.rebuildMarketData() # Passing on the events for changes in model to abstract model - self.events.on(SIGNAL_TOKENS_LIST_ABOUT_TO_BE_UPDATED) do(e: Args): - self.view.modelsAboutToUpdate() self.events.on(SIGNAL_TOKENS_LIST_UPDATED) do(e: Args): self.view.modelsUpdated() self.view.setTokenListUpdatedAt(self.controller.getTokenListUpdatedAt()) diff --git a/src/app/modules/main/wallet_section/all_tokens/sources_of_tokens_model.nim b/src/app/modules/main/wallet_section/all_tokens/sources_of_tokens_model.nim index 2f2f04ce06..0300b51c76 100644 --- a/src/app/modules/main/wallet_section/all_tokens/sources_of_tokens_model.nim +++ b/src/app/modules/main/wallet_section/all_tokens/sources_of_tokens_model.nim @@ -69,8 +69,6 @@ QtObject: of ModelRole.TokensCount: result = newQVariant(item.tokensCount) - proc modelsAboutToUpdate*(self: SourcesOfTokensModel) = - self.beginResetModel() - proc modelsUpdated*(self: SourcesOfTokensModel) = + self.beginResetModel() self.endResetModel() diff --git a/src/app/modules/main/wallet_section/all_tokens/token_by_symbol_model.nim b/src/app/modules/main/wallet_section/all_tokens/token_by_symbol_model.nim index 94294ee728..b379462daa 100644 --- a/src/app/modules/main/wallet_section/all_tokens/token_by_symbol_model.nim +++ b/src/app/modules/main/wallet_section/all_tokens/token_by_symbol_model.nim @@ -128,12 +128,10 @@ QtObject: of ModelRole.MarketDetailsLoading: result = newQVariant(self.delegate.getTokensMarketValuesLoading()) - proc modelsAboutToUpdate*(self: TokensBySymbolModel) = + proc modelsUpdated*(self: TokensBySymbolModel) = + self.beginResetModel() self.tokenMarketDetails = @[] self.addressPerChainModel = @[] - self.beginResetModel() - - proc modelsUpdated*(self: TokensBySymbolModel) = let tokensList = self.delegate.getTokenBySymbolList() for index in countup(0, tokensList.len-1): self.addressPerChainModel.add(newAddressPerChainModel(self.delegate, index)) diff --git a/src/app/modules/main/wallet_section/all_tokens/view.nim b/src/app/modules/main/wallet_section/all_tokens/view.nim index b3da3f335b..9789cde875 100644 --- a/src/app/modules/main/wallet_section/all_tokens/view.nim +++ b/src/app/modules/main/wallet_section/all_tokens/view.nim @@ -116,11 +116,6 @@ QtObject: read = getTokensBySymbolModel notify = tokensBySymbolModelChanged - proc modelsAboutToUpdate*(self: View) = - self.sourcesOfTokensModel.modelsAboutToUpdate() - self.flatTokensModel.modelsAboutToUpdate() - self.tokensBySymbolModel.modelsAboutToUpdate() - proc modelsUpdated*(self: View) = self.sourcesOfTokensModel.modelsUpdated() self.flatTokensModel.modelsUpdated() diff --git a/src/app/modules/main/wallet_section/assets/grouped_account_assets_model.nim b/src/app/modules/main/wallet_section/assets/grouped_account_assets_model.nim index af03abceee..4b75dbf25f 100644 --- a/src/app/modules/main/wallet_section/assets/grouped_account_assets_model.nim +++ b/src/app/modules/main/wallet_section/assets/grouped_account_assets_model.nim @@ -58,17 +58,18 @@ QtObject: of ModelRole.Balances: result = newQVariant(self.balancesPerChain[index.row]) - proc modelsAboutToUpdate*(self: Model) = - self.beginResetModel() - proc modelsUpdated*(self: Model) = + self.beginResetModel() let lengthOfGroupedAssets = self.delegate.getGroupedAccountsAssetsList().len let balancesPerChainLen = self.balancesPerChain.len let diff = abs(lengthOfGroupedAssets - balancesPerChainLen) + # Please note that in case more tokens are added either due to refresh or adding of new accounts + # new entries to fetch balances data are created. + # On the other hand we are not deleting in case the assets disappear either on refresh + # as there is no balance or accounts were deleted because it causes a crash on UI. + # Also this will automatically be removed on the next time app is restarted if lengthOfGroupedAssets > balancesPerChainLen: for i in countup(0, diff-1): self.balancesPerChain.add(newBalancesModel(self.delegate, balancesPerChainLen+i)) - elif lengthOfGroupedAssets < balancesPerChainLen: - self.balancesPerChain.delete(balancesPerChainLen - diff, balancesPerChainLen-1) self.endResetModel() self.countChanged() diff --git a/src/app/modules/main/wallet_section/assets/module.nim b/src/app/modules/main/wallet_section/assets/module.nim index f6ce2d2fe8..f34e3a24e9 100644 --- a/src/app/modules/main/wallet_section/assets/module.nim +++ b/src/app/modules/main/wallet_section/assets/module.nim @@ -44,9 +44,6 @@ method delete*(self: Module) = method load*(self: Module) = singletonInstance.engine.setRootContextProperty("walletSectionAssets", newQVariant(self.view)) - self.events.on(SIGNAL_WALLET_ACCOUNT_TOKENS_BEING_FETCHED) do(e:Args): - self.view.modelsAboutToUpdate() - self.events.on(SIGNAL_WALLET_ACCOUNT_TOKENS_REBUILT) do(e:Args): self.view.modelsUpdated() self.view.setHasBalanceCache(self.controller.getHasBalanceCache()) diff --git a/src/app/modules/main/wallet_section/assets/view.nim b/src/app/modules/main/wallet_section/assets/view.nim index 73818caf5a..c31aff4e9b 100644 --- a/src/app/modules/main/wallet_section/assets/view.nim +++ b/src/app/modules/main/wallet_section/assets/view.nim @@ -56,8 +56,5 @@ QtObject: self.hasMarketValuesCache = hasMarketValuesCache self.hasMarketValuesCacheChanged() - proc modelsAboutToUpdate*(self: View) = - self.groupedAccountAssetsModel.modelsAboutToUpdate() - proc modelsUpdated*(self: View) = self.groupedAccountAssetsModel.modelsUpdated() diff --git a/src/app_service/service/token/service.nim b/src/app_service/service/token/service.nim index e3dc41a233..7d89f9ead8 100644 --- a/src/app_service/service/token/service.nim +++ b/src/app_service/service/token/service.nim @@ -33,7 +33,6 @@ const CRYPTO_SUB_UNITS_TO_FACTOR = { const SIGNAL_TOKEN_HISTORICAL_DATA_LOADED* = "tokenHistoricalDataLoaded" const SIGNAL_BALANCE_HISTORY_DATA_READY* = "tokenBalanceHistoryDataReady" const SIGNAL_TOKENS_LIST_UPDATED* = "tokensListUpdated" -const SIGNAL_TOKENS_LIST_ABOUT_TO_BE_UPDATED* = "tokensListAboutToBeUpdated" const SIGNAL_TOKENS_DETAILS_ABOUT_TO_BE_UPDATED* = "tokensDetailsAboutToBeUpdated" const SIGNAL_TOKENS_DETAILS_UPDATED* = "tokensDetailsUpdated" const SIGNAL_TOKENS_MARKET_VALUES_ABOUT_TO_BE_UPDATED* = "tokensMarketValuesAboutToBeUpdated" @@ -342,8 +341,6 @@ QtObject: error "error: ", errDesription proc getSupportedTokensList*(self: Service) = - # this is emited so that the models can know that an update is about to happen - self.events.emit(SIGNAL_TOKENS_LIST_ABOUT_TO_BE_UPDATED, Args()) let arg = QObjectTaskArg( tptr: cast[ByteAddress](getSupportedTokenList), vptr: cast[ByteAddress](self.vptr), diff --git a/src/app_service/service/wallet_account/service_token.nim b/src/app_service/service/wallet_account/service_token.nim index f9d1e9a9f1..921649de91 100644 --- a/src/app_service/service/wallet_account/service_token.nim +++ b/src/app_service/service/wallet_account/service_token.nim @@ -80,9 +80,6 @@ proc buildAllTokens*(self: Service, accounts: seq[string], store: bool) = for waddress in accounts: self.updateAssetsLoadingState(waddress, true) - # this is emited so that the models can know that an update is about to happen - self.events.emit(SIGNAL_WALLET_ACCOUNT_TOKENS_BEING_FETCHED, Args()) - let arg = BuildTokensTaskArg( tptr: cast[ByteAddress](prepareTokensTask), vptr: cast[ByteAddress](self.vptr), diff --git a/src/app_service/service/wallet_account/signals_and_payloads.nim b/src/app_service/service/wallet_account/signals_and_payloads.nim index f283c84134..d5ac741db5 100644 --- a/src/app_service/service/wallet_account/signals_and_payloads.nim +++ b/src/app_service/service/wallet_account/signals_and_payloads.nim @@ -13,7 +13,6 @@ const SIGNAL_WALLET_ACCOUNT_DELETED* = "walletAccount/accountDeleted" const SIGNAL_WALLET_ACCOUNT_UPDATED* = "walletAccount/walletAccountUpdated" const SIGNAL_WALLET_ACCOUNT_NETWORK_ENABLED_UPDATED* = "walletAccount/networkEnabledUpdated" const SIGNAL_WALLET_ACCOUNT_TOKENS_REBUILT* = "walletAccount/tokensRebuilt" -const SIGNAL_WALLET_ACCOUNT_TOKENS_BEING_FETCHED* = "walletAccount/tokenFetching" const SIGNAL_WALLET_ACCOUNT_DERIVED_ADDRESSES_FETCHED* = "walletAccount/derivedAddressesFetched" const SIGNAL_WALLET_ACCOUNT_DERIVED_ADDRESSES_FROM_MNEMONIC_FETCHED* = "walletAccount/derivedAddressesFromMnemonicFetched" const SIGNAL_WALLET_ACCOUNT_ADDRESS_DETAILS_FETCHED* = "walletAccount/addressDetailsFetched"