From 19a6ba915ca041827f95b905dedea0e7bed8c884 Mon Sep 17 00:00:00 2001 From: Khushboo Mehta Date: Fri, 5 Jan 2024 16:31:56 +0530 Subject: [PATCH] fix(@desktop/wallet): Improving performance when switching accounts --- .../main/wallet_section/assets/view.nim | 2 +- ui/imports/shared/views/AssetsView.qml | 20 ++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/app/modules/main/wallet_section/assets/view.nim b/src/app/modules/main/wallet_section/assets/view.nim index f9e25e3b77..30a6e7fce8 100644 --- a/src/app/modules/main/wallet_section/assets/view.nim +++ b/src/app/modules/main/wallet_section/assets/view.nim @@ -37,7 +37,7 @@ QtObject: proc assetsChanged(self: View) {.signal.} proc getAssets*(self: View): QVariant {.slot.} = - return newQVariant(self.groupedAccountAssetsModel) + return newQVariant(self.assets) QtProperty[QVariant] assets: read = getAssets notify = assetsChanged diff --git a/ui/imports/shared/views/AssetsView.qml b/ui/imports/shared/views/AssetsView.qml index 649c98d01d..a815f8b54a 100644 --- a/ui/imports/shared/views/AssetsView.qml +++ b/ui/imports/shared/views/AssetsView.qml @@ -77,13 +77,14 @@ ColumnLayout { submodelRoleName: "balances" delegateModel: SortFilterProxyModel { sourceModel: submodel - filters: ExpressionFilter { + filters: FastExpressionFilter { expression: { root.networkFilters root.addressFilters - return root.networkFilters.split(":").includes(chainId+"") && - (!!root.addressFilters ? root.addressFilters.toUpperCase() === account.toUpperCase() : true) + return root.networkFilters.split(":").includes(model.chainId+"") && + (!!root.addressFilters ? root.addressFilters.toUpperCase() === model.account.toUpperCase() : true) } + expectedRoles: ["chainId", "account"] } } } @@ -108,15 +109,14 @@ ColumnLayout { FastExpressionRole { name: "currentCurrencyBalance" expression: { - let totalBalance = d.getTotalBalance(model.balances, model.decimals, root.addressFilters, root.networkFilters) if(!model.communityId) { - return totalBalance * model.marketDetails.currencyPrice.amount + return model.currentBalance * model.marketDetails.currencyPrice.amount } else { - return totalBalance + return model.currentBalance } } - expectedRoles: ["balances", "marketDetails", "decimals", "communityId"] + expectedRoles: ["marketDetails", "communityId", "currentBalance"] }, FastExpressionRole { name: "tokenPrice" @@ -135,23 +135,25 @@ ColumnLayout { } ] filters: [ - ExpressionFilter { + FastExpressionFilter { expression: { d.controller.settingsDirty return d.tokenIsVisible(model.symbol, model.currentCurrencyBalance) } + expectedRoles: ["symbol", "currentCurrencyBalance"] } ] sorters: [ RoleSorter { roleName: "isCommunityAsset" }, - ExpressionSorter { + FastExpressionSorter { expression: { d.controller.settingsDirty return d.controller.lessThan(modelLeft.symbol, modelRight.symbol) } enabled: d.isCustomView + expectedRoles: ["symbol"] }, RoleSorter { roleName: cmbTokenOrder.currentSortRoleName