fix(@desktop/wallet): fixing crash on switching testnet model from on to off
This commit is contained in:
parent
74bcdbe2c3
commit
3865c68737
|
@ -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: ""
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -56,8 +56,5 @@ QtObject:
|
|||
self.hasMarketValuesCache = hasMarketValuesCache
|
||||
self.hasMarketValuesCacheChanged()
|
||||
|
||||
proc modelsAboutToUpdate*(self: View) =
|
||||
self.groupedAccountAssetsModel.modelsAboutToUpdate()
|
||||
|
||||
proc modelsUpdated*(self: View) =
|
||||
self.groupedAccountAssetsModel.modelsUpdated()
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue