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 91c12d3a32..9e35671d22 100644 --- a/src/app/modules/main/wallet_section/all_tokens/view.nim +++ b/src/app/modules/main/wallet_section/all_tokens/view.nim @@ -203,8 +203,14 @@ QtObject: proc getDisplayAssetsBelowBalanceThreshold(self: View): QVariant {.slot.} = return newQVariant(self.delegate.getDisplayAssetsBelowBalanceThreshold()) - proc setDisplayAssetsBelowBalanceThreshold(self: View, threshold: int) {.slot.} = - if not self.delegate.setDisplayAssetsBelowBalanceThreshold(int64(threshold)): + proc setDisplayAssetsBelowBalanceThreshold(self: View, threshold: string) {.slot.} = + var num: int64 + try: + num = parseInt(threshold) + except ValueError: + error "Failed to parse displayAssetsBelowBalanceThreshold" + return + if not self.delegate.setDisplayAssetsBelowBalanceThreshold(num): error "Failed to set displayAssetsBelowBalanceThreshold" return self.displayAssetsBelowBalanceThresholdChanged() diff --git a/storybook/pages/AssetsViewPage.qml b/storybook/pages/AssetsViewPage.qml index 32f6246b9a..29b29696b7 100644 --- a/storybook/pages/AssetsViewPage.qml +++ b/storybook/pages/AssetsViewPage.qml @@ -12,6 +12,7 @@ import StatusQ.Core.Utils 0.1 as SQUtils import mainui 1.0 import utils 1.0 +import shared.controls 1.0 import shared.views 1.0 import shared.stores 1.0 @@ -33,28 +34,21 @@ SplitView { id: d readonly property string networksChainsCurrentlySelected: { - let supportNwChains = ":" - for (let i =0; i< networksRepeater.count; i++) { + let supportedNwChains = [] + for (let i = 0; i< networksRepeater.count; i++) { if (networksRepeater.itemAt(i).checked && networksRepeater.itemAt(i).visible) - supportNwChains += networksRepeater.itemAt(i).chainID + ":" + supportedNwChains.push(networksRepeater.itemAt(i).chainID) } - return supportNwChains + return supportedNwChains.join(":") } readonly property string addressesSelected: { - let supportedAddresses = "" - let allChecked = true - let allUnchecked = true - for (let i =0; i< accountsRepeater.count; i++) { + let supportedAddresses = [] + for (let i = 0; i< accountsRepeater.count; i++) { if (accountsRepeater.itemAt(i).checked && accountsRepeater.itemAt(i).visible) - supportedAddresses += accountsRepeater.itemAt(i).address - allChecked = allChecked && accountsRepeater.itemAt(i).checked - allUnchecked = allUnchecked && !accountsRepeater.itemAt(i).checked + supportedAddresses.push(accountsRepeater.itemAt(i).address) } - if(allChecked || allUnchecked) { - supportedAddresses = "" - } - return supportedAddresses + return supportedAddresses.join(":") } readonly property var currencyStore: CurrenciesStore {} @@ -70,13 +64,12 @@ SplitView { submodelRoleName: "balances" delegateModel: SortFilterProxyModel { sourceModel: submodel - filters: ExpressionFilter { + filters: FastExpressionFilter { expression: { d.networksChainsCurrentlySelected - d.addressesSelected - return d.networksChainsCurrentlySelected.split(":").includes(chainId+"") && - (!!d.addressesSelected ? d.addressesSelected.toUpperCase() === account.toUpperCase() : true) + return d.networksChainsCurrentlySelected.split(":").includes(model.chainId+"") } + expectedRoles: ["chainId"] } } } @@ -118,6 +111,10 @@ SplitView { } filterVisible: ctrlFilterVisible.checked currencyStore: d.currencyStore + tokensStore: TokensStore { + displayAssetsBelowBalance: ctrlBalanceThresholdSwitch.checked + getDisplayAssetsBelowBalanceThresholdDisplayAmount: () => ctrlBalanceThreshold.value + } networkFilters: d.networksChainsCurrentlySelected addressFilters: d.addressesSelected onAssetClicked: { @@ -206,6 +203,19 @@ SplitView { } } } + + ColumnLayout { + Layout.fillWidth: true + Switch { + id: ctrlBalanceThresholdSwitch + text: qsTr("Currency balance threshold") + checked: false + } + CurrencyAmountInput { + id: ctrlBalanceThreshold + value: 10.1 + } + } } } } diff --git a/storybook/src/Models/GroupedAccountsAssetsModel.qml b/storybook/src/Models/GroupedAccountsAssetsModel.qml index 7b0c936e20..91052a265b 100644 --- a/storybook/src/Models/GroupedAccountsAssetsModel.qml +++ b/storybook/src/Models/GroupedAccountsAssetsModel.qml @@ -8,7 +8,7 @@ ListModel { tokensKey: "DAI", balances: [ { account: "0x7F47C2e18a4BBf5487E6fb082eC2D9Ab0E6d7240", chainId: 5, balance: "0"}, - { account: "0x7F47C2e98a4BBf5487E6fb082eC2D9Ab0E6d8881", chainId: 5, balance: "0"} + { account: "0x7F47C2e98a4BBf5487E6fb082eC2D9Ab0E6d8881", chainId: 5, balance: "123456789123456789"} ] }, { diff --git a/storybook/stubs/AppLayouts/Wallet/stores/TokensStore.qml b/storybook/stubs/AppLayouts/Wallet/stores/TokensStore.qml index e529905281..a846ebecfe 100644 --- a/storybook/stubs/AppLayouts/Wallet/stores/TokensStore.qml +++ b/storybook/stubs/AppLayouts/Wallet/stores/TokensStore.qml @@ -2,4 +2,7 @@ import QtQuick 2.15 QtObject { id: root + + property bool displayAssetsBelowBalance: false + property var getDisplayAssetsBelowBalanceThresholdDisplayAmount } diff --git a/ui/app/AppLayouts/Profile/views/wallet/ManageTokensView.qml b/ui/app/AppLayouts/Profile/views/wallet/ManageTokensView.qml index 9a21be4696..2438409309 100644 --- a/ui/app/AppLayouts/Profile/views/wallet/ManageTokensView.qml +++ b/ui/app/AppLayouts/Profile/views/wallet/ManageTokensView.qml @@ -173,7 +173,7 @@ Item { property bool dirty: false - property var thresholdCurrency: root.tokensStore.getDisplayAssetsBelowBalanceThresholdCurrency() + readonly property var thresholdCurrency: root.tokensStore.getDisplayAssetsBelowBalanceThresholdCurrency() spacing: 8 StatusListItem { diff --git a/ui/app/AppLayouts/Wallet/views/RightTabView.qml b/ui/app/AppLayouts/Wallet/views/RightTabView.qml index 2c83f12687..7961b0ec6a 100644 --- a/ui/app/AppLayouts/Wallet/views/RightTabView.qml +++ b/ui/app/AppLayouts/Wallet/views/RightTabView.qml @@ -149,6 +149,7 @@ RightTabBaseView { overview: RootStore.overview currencyStore: RootStore.currencyStore networkConnectionStore: root.networkConnectionStore + tokensStore: RootStore.tokensStore assetDetailsLaunched: stack.currentIndex === 2 filterVisible: filterButton.checked onAssetClicked: { diff --git a/ui/imports/shared/stores/send/TransactionStore.qml b/ui/imports/shared/stores/send/TransactionStore.qml index b5e02848d9..a8bbd7162c 100644 --- a/ui/imports/shared/stores/send/TransactionStore.qml +++ b/ui/imports/shared/stores/send/TransactionStore.qml @@ -303,7 +303,7 @@ QtObject { } return 0 } - expectedRoles: ["marketDetails", "currentBalance", "symbol"] + expectedRoles: ["marketDetails", "currentBalance"] } ] filters: [ @@ -324,12 +324,17 @@ QtObject { }, FastExpressionFilter { expression: { + root.walletAssetStore.assetsController.revision + + if (!root.walletAssetStore.assetsController.filterAcceptsSymbol(model.symbol)) // explicitely hidden + return false if (model.isCommunityAsset) return true - return model.currentCurrencyBalance > processedAssetsModel.displayAssetsBelowBalanceThresholdAmount + if (tokensStore.displayAssetsBelowBalance) + return model.currentCurrencyBalance > processedAssetsModel.displayAssetsBelowBalanceThresholdAmount + return true } - expectedRoles: ["isCommunityAsset", "currentCurrencyBalance"] - enabled: tokensStore.displayAssetsBelowBalance + expectedRoles: ["symbol", "isCommunityAsset", "currentCurrencyBalance"] } ] sorters: RoleSorter { diff --git a/ui/imports/shared/views/AssetsView.qml b/ui/imports/shared/views/AssetsView.qml index 7e614f636e..908ec7a7d7 100644 --- a/ui/imports/shared/views/AssetsView.qml +++ b/ui/imports/shared/views/AssetsView.qml @@ -32,6 +32,7 @@ ColumnLayout { property var currencyStore property var networkConnectionStore + required property var tokensStore property var overview property bool assetDetailsLaunched: false property bool filterVisible @@ -54,12 +55,19 @@ ColumnLayout { readonly property bool isCustomView: cmbTokenOrder.currentValue === SortOrderComboBox.TokenOrderCustom - function tokenIsVisible(symbol) { + function tokenIsVisible(symbol, currentCurrencyBalance, isCommunityAsset) { // NOTE Backend returns ETH, SNT, STT and DAI by default if (!root.controller.filterAcceptsSymbol(symbol)) // explicitely hidden return false - // Received tokens can have 0 balance, which indicate previosuly owned token - return true // TODO handle UI threshold (#12611) + if (isCommunityAsset) + return true + // Received tokens can have 0 balance, which indicate previously owned token + if (root.tokensStore.displayAssetsBelowBalance) { + const threshold = root.tokensStore.getDisplayAssetsBelowBalanceThresholdDisplayAmount() + if (threshold > 0) + return currentCurrencyBalance > threshold + } + return true } function getTotalBalance(balances, decimals, key) { @@ -89,13 +97,11 @@ ColumnLayout { expression: { if(!model.communityId) { if (!!model.marketDetails) { - return model.currentBalance * model.marketDetails.currencyPrice.amount - } + return model.currentBalance * model.marketDetails.currencyPrice.amount + } return 0 } - else { - return model.currentBalance - } + return model.currentBalance } expectedRoles: ["marketDetails", "communityId", "currentBalance"] }, @@ -126,9 +132,10 @@ ColumnLayout { FastExpressionFilter { expression: { root.controller.revision - return d.tokenIsVisible(model.symbol) + root.tokensStore.displayAssetsBelowBalance + return d.tokenIsVisible(model.symbol, model.currentCurrencyBalance, model.isCommunityAsset) } - expectedRoles: ["symbol"] + expectedRoles: ["symbol", "currentCurrencyBalance", "isCommunityAsset"] } ] sorters: [ @@ -337,7 +344,7 @@ ColumnLayout { onTriggered: root.manageTokensRequested() } StatusAction { - enabled: symbol !== "ETH" + enabled: symbol !== Constants.ethToken type: StatusAction.Type.Danger icon.name: "hide" text: qsTr("Hide asset") diff --git a/vendor/status-go b/vendor/status-go index c7e7445f5c..296b44f9ab 160000 --- a/vendor/status-go +++ b/vendor/status-go @@ -1 +1 @@ -Subproject commit c7e7445f5c68ab9a9196cc3db5d3bba32292f8da +Subproject commit 296b44f9ab5a0e1d987dfb07bbb213145951f639