From 6762630e51be2fdcd6c7ea5d597077ec21935462 Mon Sep 17 00:00:00 2001 From: Stefan Date: Thu, 4 Apr 2024 17:41:43 +0300 Subject: [PATCH] fix(SendModal): fix not showing tokens in the holding selector The previous attempt to control the order of delegate intantiation and avoid qml warnings didn't work for this case (Loader with injected properties). Therefore, I reverted to the last working version. --- .../controls/TokenBalancePerChainDelegate.qml | 8 +-- .../popups/send/panels/HoldingSelector.qml | 70 ++++++++----------- 2 files changed, 30 insertions(+), 48 deletions(-) diff --git a/ui/imports/shared/popups/send/controls/TokenBalancePerChainDelegate.qml b/ui/imports/shared/popups/send/controls/TokenBalancePerChainDelegate.qml index 7ef6803f11..b13ad5c7b3 100644 --- a/ui/imports/shared/popups/send/controls/TokenBalancePerChainDelegate.qml +++ b/ui/imports/shared/popups/send/controls/TokenBalancePerChainDelegate.qml @@ -12,12 +12,6 @@ import utils 1.0 StatusListItem { id: root - required property var model - required property string name - required property string symbol - required property int decimals - required property var balances - signal tokenSelected(var selectedToken) signal tokenHovered(var selectedToken, bool hovered) property var formatCurrentCurrencyAmount: function(balance){} @@ -55,7 +49,7 @@ StatusListItem { return root.formatCurrentCurrencyAmount(balance) } // Community assets have a dedicated image streamed from status-go - asset.name: !!model.image + asset.name: !!model && !!model.image ? model.image : Constants.tokenIcon(symbol) asset.isImage: true diff --git a/ui/imports/shared/popups/send/panels/HoldingSelector.qml b/ui/imports/shared/popups/send/panels/HoldingSelector.qml index b7340dfe87..7f37f7cddd 100644 --- a/ui/imports/shared/popups/send/panels/HoldingSelector.qml +++ b/ui/imports/shared/popups/send/panels/HoldingSelector.qml @@ -200,52 +200,40 @@ Item { property bool hasCommunityTokens: false comboBoxDelegate: Item { - property var itemModel: model // read 'model' from the delegate's context - width: loader.width - height: loader.height - Loader { - id: loader + property var itemModel: model // read 'model' from the delegate's context + width: loader.width + height: loader.height + Loader { + id: loader - // inject model properties to the loaded item's context - // common - property var model: itemModel - property var chainId: model.chainId - property var name: model.name - property var tokenType: model.tokenType - // asset - property var symbol: model.symbol - property var totalBalance: model.totalBalance - property var marketDetails: model.marketDetails - property var decimals: model.decimals - property var balances: model.balances - // collectible - property var uid: model.uid - property var iconUrl: model.iconUrl - property var networkIconUrl: model.networkIconUrl - property var groupId: model.groupId - property var groupName: model.groupName - property var isGroup: model.isGroup - property var count: model.count - } - } + // inject model properties to the loaded item's context + // common + property var model: itemModel + property var chainId: model.chainId + property var name: model.name + property var tokenType: model.tokenType + // asset + property var symbol: model.symbol + property var totalBalance: model.totalBalance + property var marketDetails: model.marketDetails + property var decimals: model.decimals + property var balances: model.balances + // collectible + property var uid: model.uid + property var iconUrl: model.iconUrl + property var networkIconUrl: model.networkIconUrl + property var groupId: model.groupId + property var groupName: model.groupName + property var isGroup: model.isGroup + property var count: model.count - // Switch models and delegate in the right order not to mix different models and delegates - function updateComponents() { - holdingItemSelector.comboBoxModel = [] - sourceComponent: d.isCurrentBrowsingTypeAsset ? assetComboBoxDelegate : collectibleComboBoxDelegate - holdingItemSelector.comboBoxModel = d.isCurrentBrowsingTypeAsset - ? root.assetsModel - : d.collectibleComboBoxModel - } - Component.onCompleted: updateComponents() - Connections { - target: d - function onIsCurrentBrowsingTypeAssetChanged() { - holdingItemSelector.updateComponents() + sourceComponent: d.isCurrentBrowsingTypeAsset ? assetComboBoxDelegate : collectibleComboBoxDelegate } } - comboBoxModel: null + comboBoxModel: d.isCurrentBrowsingTypeAsset + ? root.assetsModel + : d.collectibleComboBoxModel comboBoxPopupHeader: headerComponent itemTextFn: d.isCurrentBrowsingTypeAsset ? d.assetTextFn : d.collectibleTextFn itemIconSourceFn: d.isCurrentBrowsingTypeAsset ? d.assetIconSourceFn : d.collectibleIconSourceFn