From ecec94b1fffa7440f2db0665e3672d4eedcba6f5 Mon Sep 17 00:00:00 2001 From: Roman Chornii Date: Fri, 19 Jul 2024 18:41:40 +0300 Subject: [PATCH] fix: Removed duplicated text in Token Popup by reusing existing supportedTokenSources mapping (#15587) fixes #14366 --- storybook/pages/TokenListPopupPage.qml | 2 +- .../Profile/panels/SupportedTokenListsPanel.qml | 10 +++++++++- ui/app/AppLayouts/Profile/popups/TokenListPopup.qml | 3 +-- ui/app/AppLayouts/Wallet/stores/TokensStore.qml | 12 ++++++------ ui/imports/utils/Constants.qml | 6 +++--- 5 files changed, 20 insertions(+), 13 deletions(-) diff --git a/storybook/pages/TokenListPopupPage.qml b/storybook/pages/TokenListPopupPage.qml index d3f298d6b4..5ad5f616ce 100644 --- a/storybook/pages/TokenListPopupPage.qml +++ b/storybook/pages/TokenListPopupPage.qml @@ -73,7 +73,7 @@ SplitView { modal: false closePolicy: Popup.NoAutoClose - sourceName: delegate.name + title: qsTr("%1 Token List").arg(delegate.name) sourceImage: delegate.image sourceUrl: delegate.source sourceVersion: delegate.version diff --git a/ui/app/AppLayouts/Profile/panels/SupportedTokenListsPanel.qml b/ui/app/AppLayouts/Profile/panels/SupportedTokenListsPanel.qml index c783f387c7..77dd994069 100644 --- a/ui/app/AppLayouts/Profile/panels/SupportedTokenListsPanel.qml +++ b/ui/app/AppLayouts/Profile/panels/SupportedTokenListsPanel.qml @@ -89,12 +89,20 @@ StatusListView { readonly property TokenListPopup popup: TokenListPopup { parent: root - sourceName: delegate.name sourceImage: delegate.image sourceUrl: delegate.source sourceVersion: delegate.version tokensCount: delegate.tokensCount + title: { + // Similar to Constants.getSupportedTokenSourceImage + if (delegate.name === Constants.supportedTokenSources.uniswap || + delegate.name === Constants.supportedTokenSources.status) + return delegate.name; + + return qsTr("%1 Token List").arg(delegate.name) + } + tokensListModel: SortFilterProxyModel { sourceModel: root.tokensListModel diff --git a/ui/app/AppLayouts/Profile/popups/TokenListPopup.qml b/ui/app/AppLayouts/Profile/popups/TokenListPopup.qml index b6df9a1f9f..b80b9a1124 100644 --- a/ui/app/AppLayouts/Profile/popups/TokenListPopup.qml +++ b/ui/app/AppLayouts/Profile/popups/TokenListPopup.qml @@ -16,7 +16,6 @@ import shared.panels 1.0 StatusDialog { id: root - required property string sourceName required property string sourceImage required property string sourceUrl required property string sourceVersion @@ -65,7 +64,7 @@ StatusDialog { } header: StatusDialogHeader { - headline.title: qsTr("%1 Token List").arg(root.sourceName) + headline.title: root.title headline.subtitle: qsTr("%n token(s)", "", root.tokensCount) actions.closeButton.onClicked: root.close() leftComponent: StatusSmartIdenticon { diff --git a/ui/app/AppLayouts/Wallet/stores/TokensStore.qml b/ui/app/AppLayouts/Wallet/stores/TokensStore.qml index 7d9531edae..d3bebddbff 100644 --- a/ui/app/AppLayouts/Wallet/stores/TokensStore.qml +++ b/ui/app/AppLayouts/Wallet/stores/TokensStore.qml @@ -19,20 +19,20 @@ QtObject { readonly property var sourcesOfTokensModel: SortFilterProxyModel { sourceModel: !!root._allTokensModule ? root._allTokensModule.sourcesOfTokensModel : null proxyRoles: FastExpressionRole { - function sourceImage(sourceKey) { - return Constants.getSupportedTokenSourceImage(sourceKey) + function sourceImage(name) { + return Constants.getSupportedTokenSourceImage(name) } name: "image" - expression: sourceImage(model.key) - expectedRoles: ["key"] + expression: sourceImage(model.name) + expectedRoles: ["name"] } filters: AnyOf { ValueFilter { - roleName: "key" + roleName: "name" value: Constants.supportedTokenSources.uniswap } ValueFilter { - roleName: "key" + roleName: "name" value: Constants.supportedTokenSources.status } } diff --git a/ui/imports/utils/Constants.qml b/ui/imports/utils/Constants.qml index 2ed019f705..3ba68169ee 100644 --- a/ui/imports/utils/Constants.qml +++ b/ui/imports/utils/Constants.qml @@ -1194,11 +1194,11 @@ QtObject { return url.indexOf("DEFAULT-TOKEN") !== -1 } - function getSupportedTokenSourceImage(key, useDefault=true) { - if (key === supportedTokenSources.uniswap) + function getSupportedTokenSourceImage(name, useDefault=true) { + if (name === supportedTokenSources.uniswap) return Style.png("tokens/UNI") - if (key === supportedTokenSources.status) + if (name === supportedTokenSources.status) return Style.png("tokens/SNT") if (useDefault)