fix: Correctly display manage tokens icons (#16228)

This commit is contained in:
Cuteivist 2024-09-03 06:07:03 +02:00 committed by GitHub
parent 9c4e1a8fe9
commit 70421a0454
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 18 additions and 4 deletions

View File

@ -421,7 +421,13 @@ void ManageTokensController::addItem(int index)
TokenData token; TokenData token;
token.symbol = symbol; token.symbol = symbol;
token.name = dataForIndex(srcIndex, kNameRoleName).toString(); token.name = dataForIndex(srcIndex, kNameRoleName).toString();
token.image = dataForIndex(srcIndex, kTokenImageUrlRoleName).toString();
if (token.image.isEmpty()) {
token.image = dataForIndex(srcIndex, kTokenImageRoleName).toString(); token.image = dataForIndex(srcIndex, kTokenImageRoleName).toString();
}
if (token.image.isEmpty()) {
token.image = dataForIndex(srcIndex, kCollectibleMediaUrlRoleName).toString();
}
if (bgColor.isValid()) if (bgColor.isValid())
token.backgroundColor = bgColor; token.backgroundColor = bgColor;
token.communityId = communityId; token.communityId = communityId;

View File

@ -123,7 +123,7 @@ QHash<int, QByteArray> ManageTokensModel::roleNames() const
{BalanceRole, kEnabledNetworkBalanceRoleName}, {BalanceRole, kEnabledNetworkBalanceRoleName},
{CurrencyBalanceRole, kEnabledNetworkCurrencyBalanceRoleName}, {CurrencyBalanceRole, kEnabledNetworkCurrencyBalanceRoleName},
{CustomSortOrderNoRole, kCustomSortOrderNoRoleName}, {CustomSortOrderNoRole, kCustomSortOrderNoRoleName},
{TokenImageRole, kTokenImageRoleName}, {TokenImageRole, kTokenImageUrlRoleName},
{TokenBackgroundColorRole, kBackgroundColorRoleName}, {TokenBackgroundColorRole, kBackgroundColorRoleName},
{TokenBalancesRole, kBalancesRoleName}, {TokenBalancesRole, kBalancesRoleName},
{TokenDecimalsRole, kDecimalsRoleName}, {TokenDecimalsRole, kDecimalsRoleName},

View File

@ -22,7 +22,9 @@ const auto kCollectionNameRoleName = QByteArrayLiteral("collectionName");
const auto kEnabledNetworkBalanceRoleName = QByteArrayLiteral("enabledNetworkBalance"); // TODO add an extra (separate role) for group->childCount const auto kEnabledNetworkBalanceRoleName = QByteArrayLiteral("enabledNetworkBalance"); // TODO add an extra (separate role) for group->childCount
const auto kEnabledNetworkCurrencyBalanceRoleName = QByteArrayLiteral("enabledNetworkCurrencyBalance"); const auto kEnabledNetworkCurrencyBalanceRoleName = QByteArrayLiteral("enabledNetworkCurrencyBalance");
const auto kCustomSortOrderNoRoleName = QByteArrayLiteral("customSortOrderNo"); const auto kCustomSortOrderNoRoleName = QByteArrayLiteral("customSortOrderNo");
const auto kTokenImageRoleName = QByteArrayLiteral("imageUrl"); const auto kTokenImageUrlRoleName = QByteArrayLiteral("imageUrl");
const auto kTokenImageRoleName = QByteArrayLiteral("image");
const auto kCollectibleMediaUrlRoleName = QByteArrayLiteral("mediaUrl");
const auto kBackgroundColorRoleName = QByteArrayLiteral("backgroundColor"); const auto kBackgroundColorRoleName = QByteArrayLiteral("backgroundColor");
const auto kBalancesRoleName = QByteArrayLiteral("balances"); const auto kBalancesRoleName = QByteArrayLiteral("balances");
const auto kDecimalsRoleName = QByteArrayLiteral("decimals"); const auto kDecimalsRoleName = QByteArrayLiteral("decimals");

View File

@ -81,7 +81,13 @@ DropArea {
: LocaleUtils.currencyAmountToLocaleString(root.getCurrencyAmount(totalBalance, model.symbol)) : LocaleUtils.currencyAmountToLocaleString(root.getCurrencyAmount(totalBalance, model.symbol))
bgRadius: priv.bgRadius bgRadius: priv.bgRadius
hasImage: true hasImage: true
icon.source: root.isCollectible ? model.imageUrl : Constants.tokenIcon(model.symbol) // TODO unify via backend model for both assets and collectibles; handle communityPrivilegesLevel icon.source: {
// TODO unify via backend model for both assets and collectibles; handle communityPrivilegesLevel
let source = root.isCollectible || root.isCommunityToken ? model.imageUrl : ""
if (source === "")
source = Constants.tokenIcon(model.symbol)
return source
}
icon.width: priv.iconSize icon.width: priv.iconSize
icon.height: priv.iconSize icon.height: priv.iconSize
spacing: 12 spacing: 12