From 70421a0454fee7f2b5c36700d67f5c5f95a7a005 Mon Sep 17 00:00:00 2001 From: Cuteivist Date: Tue, 3 Sep 2024 06:07:03 +0200 Subject: [PATCH] fix: Correctly display manage tokens icons (#16228) --- ui/StatusQ/src/wallet/managetokenscontroller.cpp | 8 +++++++- ui/StatusQ/src/wallet/managetokensmodel.cpp | 2 +- ui/StatusQ/src/wallet/managetokensmodel.h | 4 +++- .../AppLayouts/Wallet/controls/ManageTokensDelegate.qml | 8 +++++++- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/ui/StatusQ/src/wallet/managetokenscontroller.cpp b/ui/StatusQ/src/wallet/managetokenscontroller.cpp index bc3f167593..75f0ed9a18 100644 --- a/ui/StatusQ/src/wallet/managetokenscontroller.cpp +++ b/ui/StatusQ/src/wallet/managetokenscontroller.cpp @@ -421,7 +421,13 @@ void ManageTokensController::addItem(int index) TokenData token; token.symbol = symbol; token.name = dataForIndex(srcIndex, kNameRoleName).toString(); - token.image = dataForIndex(srcIndex, kTokenImageRoleName).toString(); + token.image = dataForIndex(srcIndex, kTokenImageUrlRoleName).toString(); + if (token.image.isEmpty()) { + token.image = dataForIndex(srcIndex, kTokenImageRoleName).toString(); + } + if (token.image.isEmpty()) { + token.image = dataForIndex(srcIndex, kCollectibleMediaUrlRoleName).toString(); + } if (bgColor.isValid()) token.backgroundColor = bgColor; token.communityId = communityId; diff --git a/ui/StatusQ/src/wallet/managetokensmodel.cpp b/ui/StatusQ/src/wallet/managetokensmodel.cpp index 89f4e1a02b..b887f295b6 100644 --- a/ui/StatusQ/src/wallet/managetokensmodel.cpp +++ b/ui/StatusQ/src/wallet/managetokensmodel.cpp @@ -123,7 +123,7 @@ QHash ManageTokensModel::roleNames() const {BalanceRole, kEnabledNetworkBalanceRoleName}, {CurrencyBalanceRole, kEnabledNetworkCurrencyBalanceRoleName}, {CustomSortOrderNoRole, kCustomSortOrderNoRoleName}, - {TokenImageRole, kTokenImageRoleName}, + {TokenImageRole, kTokenImageUrlRoleName}, {TokenBackgroundColorRole, kBackgroundColorRoleName}, {TokenBalancesRole, kBalancesRoleName}, {TokenDecimalsRole, kDecimalsRoleName}, diff --git a/ui/StatusQ/src/wallet/managetokensmodel.h b/ui/StatusQ/src/wallet/managetokensmodel.h index bd671b0820..d6f214d1ce 100644 --- a/ui/StatusQ/src/wallet/managetokensmodel.h +++ b/ui/StatusQ/src/wallet/managetokensmodel.h @@ -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 kEnabledNetworkCurrencyBalanceRoleName = QByteArrayLiteral("enabledNetworkCurrencyBalance"); 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 kBalancesRoleName = QByteArrayLiteral("balances"); const auto kDecimalsRoleName = QByteArrayLiteral("decimals"); diff --git a/ui/app/AppLayouts/Wallet/controls/ManageTokensDelegate.qml b/ui/app/AppLayouts/Wallet/controls/ManageTokensDelegate.qml index 347fc86a14..1b31457f7c 100644 --- a/ui/app/AppLayouts/Wallet/controls/ManageTokensDelegate.qml +++ b/ui/app/AppLayouts/Wallet/controls/ManageTokensDelegate.qml @@ -81,7 +81,13 @@ DropArea { : LocaleUtils.currencyAmountToLocaleString(root.getCurrencyAmount(totalBalance, model.symbol)) bgRadius: priv.bgRadius 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.height: priv.iconSize spacing: 12