fix: Removed duplicated text in Token Popup by reusing existing supportedTokenSources mapping (#15587)

fixes #14366
This commit is contained in:
Roman Chornii 2024-07-19 18:41:40 +03:00 committed by GitHub
parent 4b30b12fee
commit ecec94b1ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 20 additions and 13 deletions

View File

@ -73,7 +73,7 @@ SplitView {
modal: false modal: false
closePolicy: Popup.NoAutoClose closePolicy: Popup.NoAutoClose
sourceName: delegate.name title: qsTr("%1 Token List").arg(delegate.name)
sourceImage: delegate.image sourceImage: delegate.image
sourceUrl: delegate.source sourceUrl: delegate.source
sourceVersion: delegate.version sourceVersion: delegate.version

View File

@ -89,12 +89,20 @@ StatusListView {
readonly property TokenListPopup popup: TokenListPopup { readonly property TokenListPopup popup: TokenListPopup {
parent: root parent: root
sourceName: delegate.name
sourceImage: delegate.image sourceImage: delegate.image
sourceUrl: delegate.source sourceUrl: delegate.source
sourceVersion: delegate.version sourceVersion: delegate.version
tokensCount: delegate.tokensCount 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 { tokensListModel: SortFilterProxyModel {
sourceModel: root.tokensListModel sourceModel: root.tokensListModel

View File

@ -16,7 +16,6 @@ import shared.panels 1.0
StatusDialog { StatusDialog {
id: root id: root
required property string sourceName
required property string sourceImage required property string sourceImage
required property string sourceUrl required property string sourceUrl
required property string sourceVersion required property string sourceVersion
@ -65,7 +64,7 @@ StatusDialog {
} }
header: StatusDialogHeader { header: StatusDialogHeader {
headline.title: qsTr("%1 Token List").arg(root.sourceName) headline.title: root.title
headline.subtitle: qsTr("%n token(s)", "", root.tokensCount) headline.subtitle: qsTr("%n token(s)", "", root.tokensCount)
actions.closeButton.onClicked: root.close() actions.closeButton.onClicked: root.close()
leftComponent: StatusSmartIdenticon { leftComponent: StatusSmartIdenticon {

View File

@ -19,20 +19,20 @@ QtObject {
readonly property var sourcesOfTokensModel: SortFilterProxyModel { readonly property var sourcesOfTokensModel: SortFilterProxyModel {
sourceModel: !!root._allTokensModule ? root._allTokensModule.sourcesOfTokensModel : null sourceModel: !!root._allTokensModule ? root._allTokensModule.sourcesOfTokensModel : null
proxyRoles: FastExpressionRole { proxyRoles: FastExpressionRole {
function sourceImage(sourceKey) { function sourceImage(name) {
return Constants.getSupportedTokenSourceImage(sourceKey) return Constants.getSupportedTokenSourceImage(name)
} }
name: "image" name: "image"
expression: sourceImage(model.key) expression: sourceImage(model.name)
expectedRoles: ["key"] expectedRoles: ["name"]
} }
filters: AnyOf { filters: AnyOf {
ValueFilter { ValueFilter {
roleName: "key" roleName: "name"
value: Constants.supportedTokenSources.uniswap value: Constants.supportedTokenSources.uniswap
} }
ValueFilter { ValueFilter {
roleName: "key" roleName: "name"
value: Constants.supportedTokenSources.status value: Constants.supportedTokenSources.status
} }
} }

View File

@ -1194,11 +1194,11 @@ QtObject {
return url.indexOf("DEFAULT-TOKEN") !== -1 return url.indexOf("DEFAULT-TOKEN") !== -1
} }
function getSupportedTokenSourceImage(key, useDefault=true) { function getSupportedTokenSourceImage(name, useDefault=true) {
if (key === supportedTokenSources.uniswap) if (name === supportedTokenSources.uniswap)
return Style.png("tokens/UNI") return Style.png("tokens/UNI")
if (key === supportedTokenSources.status) if (name === supportedTokenSources.status)
return Style.png("tokens/SNT") return Style.png("tokens/SNT")
if (useDefault) if (useDefault)