fix(wallet): Show community name in tag (#14622)

This commit is contained in:
Cuteivist 2024-05-15 11:14:46 +02:00 committed by GitHub
parent 8b8af40979
commit 2565c8a135
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 79 additions and 20 deletions

View File

@ -22,10 +22,7 @@ type
Ownership
# Community-related roles
CommunityId
CommunityName
CommunityColor
CommunityPrivilegesLevel
CommunityImage
TokenType
Soulbound
@ -145,10 +142,7 @@ QtObject:
CollectibleRole.IsLoading.int:"isLoading",
CollectibleRole.Ownership.int:"ownership",
CollectibleRole.CommunityId.int:"communityId",
CollectibleRole.CommunityName.int:"communityName",
CollectibleRole.CommunityColor.int:"communityColor",
CollectibleRole.CommunityPrivilegesLevel.int:"communityPrivilegesLevel",
CollectibleRole.CommunityImage.int:"communityImage",
CollectibleRole.TokenType.int:"tokenType",
CollectibleRole.Soulbound.int:"soulbound"
}.toTable
@ -195,14 +189,8 @@ QtObject:
result = item.getOwnershipModelAsVariant()
of CollectibleRole.CommunityId:
result = newQVariant(item.getCommunityId())
of CollectibleRole.CommunityName:
result = newQVariant(item.getCommunityName())
of CollectibleRole.CommunityColor:
result = newQVariant(item.getCommunityColor())
of CollectibleRole.CommunityPrivilegesLevel:
result = newQVariant(item.getCommunityPrivilegesLevel())
of CollectibleRole.CommunityImage:
result = newQVariant(item.getCommunityImage())
of CollectibleRole.TokenType:
result = newQVariant(item.getTokenType())
of CollectibleRole.Soulbound:
@ -227,10 +215,7 @@ QtObject:
of "collectionSlug": result = item.getCollectionSlug()
of "isLoading": result = $false
of "communityId": result = item.getCommunityID()
of "communityName": result = item.getCommunityName()
of "communityColor": result = item.getCommunityColor()
of "communityPrivilegesLevel": result = $item.getCommunityPrivilegesLevel()
of "communityImage": result = item.getCommunityImage()
proc resetCollectibleItems(self: Model, newItems: seq[CollectiblesEntry] = @[]) =
self.beginResetModel()

View File

@ -3,6 +3,7 @@ import QtQuick 2.13
import utils 1.0
import StatusQ 0.1
import StatusQ.Models 0.1
import StatusQ.Core.Utils 0.1
import SortFilterProxyModel 0.2
@ -13,7 +14,7 @@ QtObject {
property var walletModule
property var accountsModule: root.walletModule.accountsModule
property var networksModuleInst: networksModule
property var collectibles: root.walletModule.collectiblesModel
property var collectibles: _jointCollectiblesBySymbolModel
property var accountSensitiveSettings: Global.appIsReady? localAccountSensitiveSettings : null
property var dappList: Global.appIsReady? dappPermissionsModule.dapps : null
@ -56,6 +57,42 @@ QtObject {
}
}
/* PRIVATE: This model renames the roles
1. "id" to "communityId"
2. "name" to "communityName"
3. "image" to "communityImage"
4. "description" to "communityDescription"
in communitiesModule.model so that it can be easily
joined with the Collectibles model */
readonly property var _renamedCommunitiesModel: RolesRenamingModel {
sourceModel: communitiesModule.model
mapping: [
RoleRename {
from: "id"
to: "communityId"
},
RoleRename {
from: "name"
to: "communityName"
},
RoleRename {
from: "image"
to: "communityImage"
},
RoleRename {
from: "description"
to: "communityDescription"
}
]
}
/* PRIVATE: This model joins the "Tokens By Symbol Model" and "Communities Model" by communityId */
property LeftJoinModel _jointCollectiblesBySymbolModel: LeftJoinModel {
leftModel: root.walletModule.collectiblesModel
rightModel: _renamedCommunitiesModel
joinRole: "communityId"
}
property string userProfilePublicKey: userProfile.pubKey
function deleteAccount(address) {

View File

@ -19,7 +19,6 @@ Control {
property string communityId
property var communityImage
property bool loading
property bool useLongTextDescription: true
property Component customBackground: Component {
Rectangle {
@ -53,7 +52,7 @@ Control {
Layout.preferredHeight: visible ? asset.width : 0
asset.width: 16
asset.height: 16
visible: root.useLongTextDescription && !!asset.source
visible: !d.unknownCommunityName && !!asset.source
Component.onCompleted: {
updateCommunityImage()

View File

@ -5,6 +5,8 @@ import StatusQ.Models 0.1
import utils 1.0
import SortFilterProxyModel 0.2
QtObject {
id: root
@ -27,7 +29,7 @@ QtObject {
}
readonly property var collectiblesController: ManageTokensController {
sourceModel: allCollectiblesModel
sourceModel: _jointCollectiblesBySymbolModel
settingsKey: "WalletCollectibles"
serializeAsCollectibles: true
@ -51,6 +53,43 @@ QtObject {
qsTr("%1 community collectibles are now visible").arg(communityName), "", "checkmark-circle",
false, Constants.ephemeralNotificationType.success, "")
}
/* PRIVATE: This model renames the roles
1. "id" to "communityId"
2. "name" to "communityName"
3. "image" to "communityImage"
4. "description" to "communityDescription"
in communitiesModule.model so that it can be easily
joined with the Collectibles model */
readonly property var _renamedCommunitiesModel: RolesRenamingModel {
sourceModel: communitiesModule.model
mapping: [
RoleRename {
from: "id"
to: "communityId"
},
RoleRename {
from: "name"
to: "communityName"
},
RoleRename {
from: "image"
to: "communityImage"
},
RoleRename {
from: "description"
to: "communityDescription"
}
]
}
/* PRIVATE: This model joins the "Tokens By Symbol Model" and "Communities Model" by communityId */
property LeftJoinModel _jointCollectiblesBySymbolModel: LeftJoinModel {
leftModel: allCollectiblesModel
rightModel: _renamedCommunitiesModel
joinRole: "communityId"
}
readonly property bool areCollectiblesFetching: !!root._allCollectiblesModel ? root._allCollectiblesModel.isFetching : true
readonly property bool areCollectiblesUpdating: !!root._allCollectiblesModel ? root._allCollectiblesModel.isUpdating : false
readonly property bool areCollectiblesError: !!root._allCollectiblesModel ? root._allCollectiblesModel.isError : false

View File

@ -189,7 +189,6 @@ Control {
communityImage: root.communityImage
visible: root.isCommunityCollectible
enabled: !root.isLoading
useLongTextDescription: false
TapHandler {
enabled: !d.unknownCommunityName